-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Proper exit codes #127
Comments
Would one be to have an I could imagine Using this approach, the errors then could be "catched" by some formatting logic to output it nicely formatted and exit the cli with a non 0 exit code. This would also mean that the main function would be |
Or something like https://docs.rs/clap/latest/clap/error/struct.Error.html#method.context |
I think specifically there's two different things here to think about:
So I think the first concrete improvement here will be to split those two scenarios and exit differently. There's really two options I see here:
I prefer the second because it's cleaner and clearer at the type level but it may be a bit more work. Once we've got that going and well separated, we can look into adding:
|
As mentioned in #113 and #116 many statments in
main.rs
after an if clause to determine if it should abort usereturn Ok(());
which ends the process but exits with the exit code0
. This makes it hard for scripts likeDockerfile
or github actions to abort ifcargo binstall
couldn't find a correct version.Changing this to
return Err(anyhow::anyhow!("Installation cancelled"));
would be a easy thing to do but in case of the provided example this would output the following thing:This means once the message via a
warn!
, nicely formatted and once plain as it is returned frommain() -> Result<(), anyhow::Error
>.My 2 cents about a solution:
anyhow
, but I haven't found a solution yetI appreciate comments and opinions, as I currently do not have a nice solution to propose
The text was updated successfully, but these errors were encountered: