ENT-3333: Return error code for invalid cmdline options (#4910)

If an invalid command line option is specified and the parser is unable to parse the input, return an error code to the caller. This is useful in scripting scenarios where it might be important to detect that Corda failed to start due to invalid command line parameters
This commit is contained in:
Jonathan Locke 2019-03-21 11:15:32 +00:00 committed by Shams Asari
parent 0ab6b4de89
commit eabd056511

View File

@ -71,7 +71,7 @@ fun CordaCliWrapper.start(args: Array<String>) {
Help.Ansi.AUTO
}
val results = cmd.parseWithHandlers(RunLast().useOut(System.out).useAnsi(defaultAnsiMode),
DefaultExceptionHandler<List<Any>>().useErr(System.err).useAnsi(defaultAnsiMode),
DefaultExceptionHandler<List<Any>>().useErr(System.err).useAnsi(defaultAnsiMode).andExit(ExitCodes.FAILURE),
*args)
// If an error code has been returned, use this and exit
results?.firstOrNull()?.let {