Skip to content
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

Exit code control from built-in handlers #251

Closed
remkop opened this issue Dec 19, 2017 · 2 comments
Closed

Exit code control from built-in handlers #251

remkop opened this issue Dec 19, 2017 · 2 comments

Comments

@remkop
Copy link
Owner

remkop commented Dec 19, 2017

Commonly, successful execution of a command should result in a zero exit code and unsuccessful invocation should result in a non-zero exit code.

The java executable does not return a non-zero exit code if the application exits because of an uncaught throwable. It’s up to the application to call System.exit(int) if control over the exit code is desired.

Picocli has a “success” path and three separate “failure” paths:

  • InitializationException if misconfigured
  • ParameterException if user input is invalid
  • ExecutionException if user input was valid but the IParseResultHandler threw an exception
  • No errors

Consider providing API to let applications control the exit code for all of the above.

See also discussion under #218 for API ideas on how to accomplish this.

@remkop
Copy link
Owner Author

remkop commented Mar 6, 2018

Note to self: look at http://stefanbirkner.github.io/system-rules/#ExpectedSystemExit to help with testing

remkop added a commit that referenced this issue Mar 6, 2018
remkop added a commit that referenced this issue Mar 6, 2018
…rules to facilitate testing exit codes and use of stdout/stderr streams
remkop added a commit that referenced this issue Mar 6, 2018
@remkop
Copy link
Owner Author

remkop commented Mar 7, 2018

Text for release notes:

  • [251] New feature: exit code support. The built-in parse result handlers (RunFirst, RunLast and RunAll) and exception handler (DefaultExceptionHandler) can now specify an exit code. If specified, the handler terminates the JVM with the specified status code when finished. Custom handlers can extend AbstractHandler to inherit this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant