@Test public void test() { Launcher.main(new String[]{}); Launcher.main(new String[]{"asdf"}); Launcher.main(new String[]{"--help"}); }
public static void main(String[] args) { try { HashMap<String, Command> commands = new LinkedHashMap<>(); commands.put("list", new ListCommand()); commands.put("report", new ReportCommand()); commands.put("experiment-single-random", new ExperimentSingleRandomCommand()); commands.put("experiment-single-feedback", new ExperimentSingleFeedbackCommand()); commands.put("experiment-single-evolution", new ExperimentSingleEvolutionCommand()); commands.put("experiment-multi-random", new ExperimentMultiRandomCommand()); Launcher launcher = new Launcher(); JCommander jc = new JCommander(launcher); for (Entry<String, Command> e : commands.entrySet()) jc.addCommand(e.getKey(), e.getValue()); jc.parse(args); if (args.length == 0 || launcher.help) { jc.usage(); return; } launcher.run(commands.get(jc.getParsedCommand())); } catch (ParameterException ex) { _logger.error(ex.getMessage()); _logger.error("Try to use --help"); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } }
Launcher { public static void main(String[] args) { try { HashMap<String, Command> commands = new LinkedHashMap<>(); commands.put("list", new ListCommand()); commands.put("report", new ReportCommand()); commands.put("experiment-single-random", new ExperimentSingleRandomCommand()); commands.put("experiment-single-feedback", new ExperimentSingleFeedbackCommand()); commands.put("experiment-single-evolution", new ExperimentSingleEvolutionCommand()); commands.put("experiment-multi-random", new ExperimentMultiRandomCommand()); Launcher launcher = new Launcher(); JCommander jc = new JCommander(launcher); for (Entry<String, Command> e : commands.entrySet()) jc.addCommand(e.getKey(), e.getValue()); jc.parse(args); if (args.length == 0 || launcher.help) { jc.usage(); return; } launcher.run(commands.get(jc.getParsedCommand())); } catch (ParameterException ex) { _logger.error(ex.getMessage()); _logger.error("Try to use --help"); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } } }
Launcher { public static void main(String[] args) { try { HashMap<String, Command> commands = new LinkedHashMap<>(); commands.put("list", new ListCommand()); commands.put("report", new ReportCommand()); commands.put("experiment-single-random", new ExperimentSingleRandomCommand()); commands.put("experiment-single-feedback", new ExperimentSingleFeedbackCommand()); commands.put("experiment-single-evolution", new ExperimentSingleEvolutionCommand()); commands.put("experiment-multi-random", new ExperimentMultiRandomCommand()); Launcher launcher = new Launcher(); JCommander jc = new JCommander(launcher); for (Entry<String, Command> e : commands.entrySet()) jc.addCommand(e.getKey(), e.getValue()); jc.parse(args); if (args.length == 0 || launcher.help) { jc.usage(); return; } launcher.run(commands.get(jc.getParsedCommand())); } catch (ParameterException ex) { _logger.error(ex.getMessage()); _logger.error("Try to use --help"); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } }  }
Launcher { public static void main(String[] args) { try { HashMap<String, Command> commands = new LinkedHashMap<>(); commands.put("list", new ListCommand()); commands.put("report", new ReportCommand()); commands.put("experiment-single-random", new ExperimentSingleRandomCommand()); commands.put("experiment-single-feedback", new ExperimentSingleFeedbackCommand()); commands.put("experiment-single-evolution", new ExperimentSingleEvolutionCommand()); commands.put("experiment-multi-random", new ExperimentMultiRandomCommand()); Launcher launcher = new Launcher(); JCommander jc = new JCommander(launcher); for (Entry<String, Command> e : commands.entrySet()) jc.addCommand(e.getKey(), e.getValue()); jc.parse(args); if (args.length == 0 || launcher.help) { jc.usage(); return; } launcher.run(commands.get(jc.getParsedCommand())); } catch (ParameterException ex) { _logger.error(ex.getMessage()); _logger.error("Try to use --help"); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } }  static void main(String[] args); }
Launcher { public static void main(String[] args) { try { HashMap<String, Command> commands = new LinkedHashMap<>(); commands.put("list", new ListCommand()); commands.put("report", new ReportCommand()); commands.put("experiment-single-random", new ExperimentSingleRandomCommand()); commands.put("experiment-single-feedback", new ExperimentSingleFeedbackCommand()); commands.put("experiment-single-evolution", new ExperimentSingleEvolutionCommand()); commands.put("experiment-multi-random", new ExperimentMultiRandomCommand()); Launcher launcher = new Launcher(); JCommander jc = new JCommander(launcher); for (Entry<String, Command> e : commands.entrySet()) jc.addCommand(e.getKey(), e.getValue()); jc.parse(args); if (args.length == 0 || launcher.help) { jc.usage(); return; } launcher.run(commands.get(jc.getParsedCommand())); } catch (ParameterException ex) { _logger.error(ex.getMessage()); _logger.error("Try to use --help"); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } }  static void main(String[] args);  }