-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
return non-zero exit code upon non-runnable subcommand #1156
Comments
/assign |
Close spf13#1156 Signed-off-by: Dong Gang <[email protected]>
Ref #842. |
This issue is being marked as stale due to a long period of inactivity |
@donggangcj , Interestingly enough I am not able to repro this. I'm curious why Helm would be yielding different results.
Upon further review. This behavior seems to be stemming from logic within Helm itself. |
@jharshman IIRC you need to specify a value for the |
@marckhouzam I see, not sure it has anything to do with error being dropped due to it being of type
So basically you can invoke your root command incorrectly and receive an error whereas sub commands after a successful root command invocation run through the above and return no error. |
This issue is being marked as stale due to a long period of inactivity |
this is still important to me (I was trying to trigger the bot,...) |
This issue is being marked as stale due to a long period of inactivity |
With the time since the original complaint I want to repro this again and make sure its still relevant. I think it is and there may even be a duplicate of this issue elsewhere but wanted to label this as part of the backlog cleanup (#1600) |
IIRC, has something to do with the |
Hello. I am also running into this. The issue happens for me when a subcommand is passed an arugment it does not understand. Instead of the program exiting with non-zero, it dumps the usage string and exits with 0. Minimal working example:
Then build, I believe if you just return the error instead of nil, this Line 1074 in fd865a4
So this:
Just propagate the error back up to the caller. I can submit this as a PR, if you'd like. |
I’d have to look back at the details but the issue was that previous fixes have caused backwards compatibility issues. |
Since my issue was closed as a duplicate to this, I would like to try to raise this issue again. I understand that changing the behavior could break backward compatibility, but is there some workaround to detect this case? |
when excuting a root comand , cobra returns success on typos and exit code is 1.
when excuting a subcommand ,cobra returns success on typos but exit code is 0.
This issue has come up before and this is related pr.
The related helm pr is here.
The text was updated successfully, but these errors were encountered: