-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): validate --output
flag and refactor
#13695
Conversation
This is a follow-up to argoproj#13656 (review). Many of the CLI commands take an `--output` flag, but this wasn't being validated, and there was a lot of duplication. The duplication has led to docs getting out-of-date, e.g. `argo cluster-template get --help` says `Output format. Must be one of: json|yaml|wide`, but it accepts `name` too. This introduces a simple `EnumFlagValue` type to represent enum flags like `--output` and changes all commands with an `--output` flag to use it. This will cause Cobra to give a helpful error if you pass an invalid value, e.g.: ``` $ ./dist/argo list -o INVALID Error: invalid argument "INVALID" for "-o, --output" flag: One of: name|json|yaml|wide ``` Signed-off-by: Mason Malone <[email protected]>
c803fd3
to
9e3c5d8
Compare
--output
validation--output
flag and refactor
Ah @MasonM I think merging the previous PR introduced a bunch of merge conflicts, sorry about this but could you please address these? Thanks |
Signed-off-by: Mason Malone <[email protected]>
Signed-off-by: Mason Malone <[email protected]>
@isubasinghe Sure, done. |
Looks like
|
/retest |
@@ -28,7 +28,7 @@ argo archive list [flags] | |||
``` | |||
--chunk-size int Return large lists in chunks rather than all at once. Pass 0 to disable. | |||
-h, --help help for list | |||
-o, --output string Output format. One of: json|yaml|wide (default "wide") | |||
-o, --output string Output format. One of: name|json|yaml|wide (default "wide") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit confused initially but this makes sense, allows for code reuse.
Motivation
This is a follow-up to #13656 (review). Many of the CLI commands take an
--output
flag, but this wasn't being validated, and there was a lot of duplication. The duplication has led to docs getting out-of-date, e.g.argo cluster-template get --help
saysOutput format. Must be one of: json|yaml|wide
, but it acceptsname
too.Modifications
This introduces a simple
EnumFlagValue
type to represent enum flags like--output
and changes all commands with an--output
flag to use it. This will cause Cobra to give a helpful error if you pass an invalid value, e.g.:Verification
Ran E2E tests and manually ran a few commands with
./dist/argo