Skip to content
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

cli: unknown flag errors cleanup #8625

Closed
danielhelfand opened this issue Mar 1, 2022 · 0 comments · Fixed by #8723
Closed

cli: unknown flag errors cleanup #8625

danielhelfand opened this issue Mar 1, 2022 · 0 comments · Fixed by #8723
Labels
component:cli Affects the Argo CD CLI enhancement New feature or request type:usability Enhancement of an existing feature

Comments

@danielhelfand
Copy link
Contributor

Summary

When I use an invalid flag with the argocd cli, I get the following output:

argocd cluster list -l  
Error: unknown shorthand flag: 'l' in -l
Usage:
  argocd cluster list [flags]

Flags:
  -h, --help            help for list
  -o, --output string   Output format. One of: json|yaml|wide|server (default "wide")

Global Flags:
      --auth-token string               Authentication token
      --client-crt string               Client certificate file
      --client-crt-key string           Client certificate key file
      --config string                   Path to Argo CD config (default "/Users/dhelfand/.argocd/config")
      --core                            If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
      --grpc-web                        Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
      --grpc-web-root-path string       Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
  -H, --header strings                  Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
      --http-retry-max int              Maximum number of retries to establish http connection to Argo CD server
      --insecure                        Skip server certificate and domain verification
      --logformat string                Set the logging format. One of: text|json (default "text")
      --loglevel string                 Set the logging level. One of: debug|info|warn|error (default "info")
      --plaintext                       Disable TLS
      --port-forward                    Connect to a random argocd-server port using port forwarding
      --port-forward-namespace string   Namespace name which should be used for port forwarding
      --server string                   Argo CD server address
      --server-crt string               Server certificate file

unknown shorthand flag: 'l' in -l

The help output can be distracting and make it difficult to find the error.

Additionally, the error message is shown twice (once toward the top as Error: unknown shorthand flag: 'l' in -l, then at the bottom as unknown shorthand flag: 'l' in -l.)

Motivation

If I ever make a flag typo when running a command.

Proposal

I think it would make sense to enable SilenceUsage from the the root command here. This would stop showing all the help information for a command when the error occurs.

I also think it's not necessary to print the error message here. The error should be surfaced before this point.

With the changes above, the command output would change to as follows:

argocd cluster list -l
Error: unknown shorthand flag: 'l' in -l
@danielhelfand danielhelfand added the enhancement New feature or request label Mar 1, 2022
@crenshaw-dev crenshaw-dev added component:cli Affects the Argo CD CLI type:usability Enhancement of an existing feature labels Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli Affects the Argo CD CLI enhancement New feature or request type:usability Enhancement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants