-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
is raise SystemExit(exit_code) the right way to return a non-zero exit status? #270
Comments
Why not use the regular python site module exit()? |
Use |
Hi, I don't create a new issue as my question is totally linked to this one : why does click so apparently "force" the return code of the function to 0 and ignore the given return value? well actually it's not that it force the return value to 0, it doesn't return but executes (force?) sys.exit() itself. with 0 whatever is the return value you actually returned from the function so.. I mean : wouldn't it be ok/better that it uses the returned value from the function to sys.exit() ? Thx for any info. |
@gst You're mixing up raising |
hi, well.. I wasn't 100% clear effectively. My question is so: couldn't I (quickly) checked the documentation and didn't find a clear statement (but I could have missed it) about how to it is supposed to be handled (the process exit code of a click.Command). Thx. |
Yeah click ignores that. You should use sys.exit instead.
…On 5 January 2017 16:21:37 CET, "Grégory Starck" ***@***.***> wrote:
hi,
well.. I wasn't 100% clear effectively.
My question is so:
couldn't `click` use the return value of a _click.Command_ decorated
function when it returns, like `diff` here above, and to sys.exit()
that value ? That is just `return cobertura1.line_rate() >
cobertura2.line_rate()` for the above.
I (quickly) checked the documentation and didn't find a clear statement
(but I could have missed it) about how to it is supposed to be handled
(the process exit code of a click.Command).
Thx.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#270 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I think the question is about why Click ignores that. That would be quite convenient, and IMHO returning the exit code makes the code look cleaner than using |
I tend to agree, if you open a complete PR with doc updates and tests and changelog, I will merge it.
…On 5 April 2017 16:48:10 CEST, Niklas Rosenstein ***@***.***> wrote:
> Yeah click ignores that. You should use sys.exit instead.
I think the question is about *why* Click ignores that. That would be
quite convenient, and IMHO returning the exit code makes the code look
cleaner than using `sys.exit()` (one of the reasons might be that
`return` is usually highlighted in editors and you will notice it much
easier than `sys.exit()` and it gives you a visual indicator of
"function can end here").
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#270 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I am confused. The documentation at https://click.palletsprojects.com/en/7.x/commands/#command-return-values states quite clearly, to me at least, that command return values are honored. Why is it that when I use |
relatedly, when one does console_script entry points, you use |
@WeatherGod I think that pretty much depends on how you wired up |
Hello, How do I custom handle click.abort exception in my code. If abort exception happens I need to close my queue that i am consuming. Kind of customize the abort exception. https://stackoverflow.com/questions/58296149/custom-exception-handling-using-python-click |
I would like to control the exit status of a command. I saw that different exceptions are available from Click which are mostly used for bad command line usage.
I just want a clean exit for a properly ran command (with no
Abort!
message). I ended up usingraise SystemExit(1)
. Is this the proper way of doing it? I was thinking that it'd be nice if the return value of the command would be the exit status.The text was updated successfully, but these errors were encountered: