Reputation: 33
I am working on a spring-shell application, my @CliCommand methods have custom logic that ends with responses like SUCCESS / FAILURE. I saw that it is possible to modify the spring-shell exit code by throwing an exception (it becomes 1).
In case of FAILURE I would like to return an exit code different from 0. Is it possible to do that without throwing an exception?
Upvotes: 2
Views: 1500
Reputation: 1997
This is not currently possible without modifying the Bootstrap/ExitShellRequest classes.
Keep in mind that Spring Shell is first and foremost meant to create interactive applications, hence the lesser emphasis on system exit codes. If however you feel this should be a supported feature, please open a ticket for it.
Lastly, the System.exit(x)
solution may work for you inside your own commands. Be wary though, that the whole shell context may not clean properly, which may be a problem.
Upvotes: 2