cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Output usage hint for both unknown subcommand and unknown flag in the same way

Open dgn opened this issue 5 years ago • 4 comments

Now, when you try to run a Command with an unknown sub-command vs. an unknown flag, you'll get:

$ testcommand asdsa
Error: unknown command "asdsa" for "testcommand"
Run 'testcommand --help' for usage.

$ testcommand --asdsa
Error: unknown flag: --asdsa

$ testcommand -asdsa
Error: unknown shorthand flag: 'a' in -asdsa

With these changes, you'll get:

$ testcommand asdsa
Error: unknown command "asdsa" for "testcommand"
Run 'testcommand --help' for usage.

$ testcommand --asdsa
Error: unknown flag: --asdsa
Run 'testcommand --help' for usage.

$ testcommand -asdsa
Error: unknown shorthand flag: 'a' in -asdsa
Run 'testcommand --help' for usage.

dgn avatar Jan 29 '20 09:01 dgn

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 06 '20 11:03 CLAassistant

This PR is being marked as stale due to a long period of inactivity

github-actions[bot] avatar May 30 '20 00:05 github-actions[bot]

Bump!

craigbox avatar Jul 30 '20 11:07 craigbox

@spf13 can you please merge this commit? We need it!

virtax avatar Sep 11 '20 13:09 virtax