You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I might be missing something completely, but there seems to be a undesirable behavior when an invalid sub-command is passed. Indeed, the help is shown, but the exit code is 0.
The following code early exit when there is the error is flag.ErrHelp which I assume is meant for when the -h is passed, but also happen when an invalid sub-command is passed.
I'm I missing something? It seems that the desirable behavior would be to return an error when an invalid sub-command is passed.
The only workaround that may work is to call ExecuteC and check that the returned sub-command is not the root command.
Edit: Nevermind, can't distinguish with an --help flag.
The text was updated successfully, but these errors were encountered:
Hey, I might be missing something completely, but there seems to be a undesirable behavior when an invalid sub-command is passed. Indeed, the help is shown, but the exit code is 0.
The following code early exit when there is the error is
flag.ErrHelp
which I assume is meant for when the-h
is passed, but also happen when an invalid sub-command is passed.cobra/command.go
Lines 1094 to 1097 in bd4d165
Indeed, in
execute()
, there is the following:cobra/command.go
Lines 918 to 920 in bd4d165
I'm I missing something? It seems that the desirable behavior would be to return an error when an invalid sub-command is passed.
The only workaround that may work is to callExecuteC
and check that the returned sub-command is not the root command.Edit: Nevermind, can't distinguish with an
--help
flag.The text was updated successfully, but these errors were encountered: