# HG changeset patch # User František Kučera # Date 1387929808 -3600 # Node ID 29f45ab3b9596d859c0066523bc21b4034f82d08 # Parent f5ed7c4efacc0b6cd2f1a6e694411982653046d1 exit codes: 0 = success; 4 = SQL error; 3 = other expected error; 1 = unexpected error (implicit 1) diff -r f5ed7c4efacc -r 29f45ab3b959 java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Wed Dec 25 00:43:06 2013 +0100 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Wed Dec 25 01:03:28 2013 +0100 @@ -40,12 +40,16 @@ public class CLIStarter implements ConfigurationProvider { private static final Logger log = Logger.getLogger(CLIStarter.class.getName()); + private static final int EXIT_SUCCESS = 0; + private static final int EXIT_EXPECTED_ERROR = 3; + private static final int EXIT_SQL_ERROR = 4; private CLIOptions options; private Configuration configuration; public static void main(String[] args) { log.log(Level.FINE, "Starting " + Constants.PROGRAM_NAME); - + int exitCode = EXIT_EXPECTED_ERROR; + if (args.length == 0) { args = new String[]{CLIParser.Tokens.INFO_HELP}; } @@ -58,6 +62,7 @@ starter.installDefaultConfiguration(); starter.process(); log.log(Level.FINE, "All done"); + exitCode = EXIT_SUCCESS; } catch (CLIParserException e) { log.log(Level.SEVERE, "Unable to parse CLI options", e); } catch (InvalidOptionsException e) { @@ -69,9 +74,12 @@ log.log(Level.SEVERE, "Configuration problem", e); } catch (SQLException e) { log.log(Level.SEVERE, "SQL problem", e); + exitCode = EXIT_SQL_ERROR; } catch (FormatterException e) { log.log(Level.SEVERE, "Formatting problem", e); } + + System.exit(exitCode); } public CLIStarter(CLIOptions options) {