Skip to content

Conversation

@OhRaph
Copy link

@OhRaph OhRaph commented Apr 24, 2024

The value of flag "--output" isn't evaluated when using command "get chaos-experiments".

This is the behavior we have:

litmusctl get chaos-experiments --project-id "066950eb-0914-49b1-8bda-b652f86cb7ab" -o="yaml"
Use the arrow keys to navigate: ↓ ↑ → ← 
? Select an output format: 
  ▸ table
    json
    yaml

Moreover:

  • the value "table" isn't mentioned in the doc
  • there is no guard to check the validity of the value provided in option "--output"

I propose to add these changes.

Note: I'm not familiar with Go language. The code I provide is mainly derived from existing one, and I've search on Internet to achieve some part I could do by myself.

Please feel free to improve it as you want.
By advance, sorry for the possible mistakes I've made.

@OhRaph
Copy link
Author

OhRaph commented Apr 24, 2024

I can see that this PR is already addressing the non evaluation of flag "--output".
But it's doesn't ensure that the value provided by argument is valid.

Signed-off-by: Raph <raphael.manger+git@gmail.com>
@Nageshbansal
Copy link
Collaborator

@shivam-Purohit could you PTAL

outputFormat, err := cmd.Flags().GetString("output")
utils.PrintError(err)

if outputFormat == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also merge the if statements into one to get rid of repeating promptui code. if == "" &&
Maybe something like input a valid output format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants