@Test public void testVersion() throws Exception { int rc = run("--version"); verify(console).info(contains("Kite version"), anyString()); assertEquals(0, rc); }
@Override public int run(String[] args) throws Exception { if (getConf() != null) { DefaultConfiguration.set(getConf()); } try { jc.parse(args); } catch (MissingCommandException e) { console.error(e.getMessage()); return 1; } catch (ParameterException e) { help.setProgramName(programName); String cmd = jc.getParsedCommand(); if (args.length == 1) { help.helpCommands.add(cmd); help.run(); return 1; } else { for (String arg : args) { if (HELP_ARGS.contains(arg)) { help.helpCommands.add(cmd); help.run(); return 0; } } } console.error(e.getMessage()); return 1; } help.setProgramName(programName); if (printVersion) { console.info("Kite version \"{}\"", getVersion()); return 0; } if (debug) { org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class); console.setLevel(Level.DEBUG); } String parsed = jc.getParsedCommand(); if (parsed == null) { help.run(); return 1; } else if ("help".equals(parsed)) { return help.run(); } Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0); if (command == null) { help.run(); return 1; } try { if (command instanceof Configurable) { ((Configurable) command).setConf(getConf()); } return command.run(); } catch (IllegalArgumentException e) { if (debug) { console.error("Argument error", e); } else { console.error("Argument error: {}", e.getMessage()); } return 1; } catch (IllegalStateException e) { if (debug) { console.error("State error", e); } else { console.error("State error: {}", e.getMessage()); } return 1; } catch (ValidationException e) { if (debug) { console.error("Validation error", e); } else { console.error("Validation error: {}", e.getMessage()); } return 1; } catch (DatasetNotFoundException e) { if (debug) { console.error("Cannot find dataset", e); } else { console.error(e.getMessage()); } return 1; } catch (DatasetIOException e) { if (debug) { console.error("IO error", e); } else { console.error("IO error: {}", e.getMessage()); } return 1; } catch (Exception e) { if (debug) { console.error("Unknown error", e); } else { console.error("Unknown error: {}", e.getMessage()); } return 1; } }
Main extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (getConf() != null) { DefaultConfiguration.set(getConf()); } try { jc.parse(args); } catch (MissingCommandException e) { console.error(e.getMessage()); return 1; } catch (ParameterException e) { help.setProgramName(programName); String cmd = jc.getParsedCommand(); if (args.length == 1) { help.helpCommands.add(cmd); help.run(); return 1; } else { for (String arg : args) { if (HELP_ARGS.contains(arg)) { help.helpCommands.add(cmd); help.run(); return 0; } } } console.error(e.getMessage()); return 1; } help.setProgramName(programName); if (printVersion) { console.info("Kite version \"{}\"", getVersion()); return 0; } if (debug) { org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class); console.setLevel(Level.DEBUG); } String parsed = jc.getParsedCommand(); if (parsed == null) { help.run(); return 1; } else if ("help".equals(parsed)) { return help.run(); } Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0); if (command == null) { help.run(); return 1; } try { if (command instanceof Configurable) { ((Configurable) command).setConf(getConf()); } return command.run(); } catch (IllegalArgumentException e) { if (debug) { console.error("Argument error", e); } else { console.error("Argument error: {}", e.getMessage()); } return 1; } catch (IllegalStateException e) { if (debug) { console.error("State error", e); } else { console.error("State error: {}", e.getMessage()); } return 1; } catch (ValidationException e) { if (debug) { console.error("Validation error", e); } else { console.error("Validation error: {}", e.getMessage()); } return 1; } catch (DatasetNotFoundException e) { if (debug) { console.error("Cannot find dataset", e); } else { console.error(e.getMessage()); } return 1; } catch (DatasetIOException e) { if (debug) { console.error("IO error", e); } else { console.error("IO error: {}", e.getMessage()); } return 1; } catch (Exception e) { if (debug) { console.error("Unknown error", e); } else { console.error("Unknown error: {}", e.getMessage()); } return 1; } } }
Main extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (getConf() != null) { DefaultConfiguration.set(getConf()); } try { jc.parse(args); } catch (MissingCommandException e) { console.error(e.getMessage()); return 1; } catch (ParameterException e) { help.setProgramName(programName); String cmd = jc.getParsedCommand(); if (args.length == 1) { help.helpCommands.add(cmd); help.run(); return 1; } else { for (String arg : args) { if (HELP_ARGS.contains(arg)) { help.helpCommands.add(cmd); help.run(); return 0; } } } console.error(e.getMessage()); return 1; } help.setProgramName(programName); if (printVersion) { console.info("Kite version \"{}\"", getVersion()); return 0; } if (debug) { org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class); console.setLevel(Level.DEBUG); } String parsed = jc.getParsedCommand(); if (parsed == null) { help.run(); return 1; } else if ("help".equals(parsed)) { return help.run(); } Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0); if (command == null) { help.run(); return 1; } try { if (command instanceof Configurable) { ((Configurable) command).setConf(getConf()); } return command.run(); } catch (IllegalArgumentException e) { if (debug) { console.error("Argument error", e); } else { console.error("Argument error: {}", e.getMessage()); } return 1; } catch (IllegalStateException e) { if (debug) { console.error("State error", e); } else { console.error("State error: {}", e.getMessage()); } return 1; } catch (ValidationException e) { if (debug) { console.error("Validation error", e); } else { console.error("Validation error: {}", e.getMessage()); } return 1; } catch (DatasetNotFoundException e) { if (debug) { console.error("Cannot find dataset", e); } else { console.error(e.getMessage()); } return 1; } catch (DatasetIOException e) { if (debug) { console.error("IO error", e); } else { console.error("IO error: {}", e.getMessage()); } return 1; } catch (Exception e) { if (debug) { console.error("Unknown error", e); } else { console.error("Unknown error: {}", e.getMessage()); } return 1; } } Main(Logger console); }
Main extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (getConf() != null) { DefaultConfiguration.set(getConf()); } try { jc.parse(args); } catch (MissingCommandException e) { console.error(e.getMessage()); return 1; } catch (ParameterException e) { help.setProgramName(programName); String cmd = jc.getParsedCommand(); if (args.length == 1) { help.helpCommands.add(cmd); help.run(); return 1; } else { for (String arg : args) { if (HELP_ARGS.contains(arg)) { help.helpCommands.add(cmd); help.run(); return 0; } } } console.error(e.getMessage()); return 1; } help.setProgramName(programName); if (printVersion) { console.info("Kite version \"{}\"", getVersion()); return 0; } if (debug) { org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class); console.setLevel(Level.DEBUG); } String parsed = jc.getParsedCommand(); if (parsed == null) { help.run(); return 1; } else if ("help".equals(parsed)) { return help.run(); } Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0); if (command == null) { help.run(); return 1; } try { if (command instanceof Configurable) { ((Configurable) command).setConf(getConf()); } return command.run(); } catch (IllegalArgumentException e) { if (debug) { console.error("Argument error", e); } else { console.error("Argument error: {}", e.getMessage()); } return 1; } catch (IllegalStateException e) { if (debug) { console.error("State error", e); } else { console.error("State error: {}", e.getMessage()); } return 1; } catch (ValidationException e) { if (debug) { console.error("Validation error", e); } else { console.error("Validation error: {}", e.getMessage()); } return 1; } catch (DatasetNotFoundException e) { if (debug) { console.error("Cannot find dataset", e); } else { console.error(e.getMessage()); } return 1; } catch (DatasetIOException e) { if (debug) { console.error("IO error", e); } else { console.error("IO error: {}", e.getMessage()); } return 1; } catch (Exception e) { if (debug) { console.error("Unknown error", e); } else { console.error("Unknown error: {}", e.getMessage()); } return 1; } } Main(Logger console); @Override int run(String[] args); static void main(String[] args); }
Main extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (getConf() != null) { DefaultConfiguration.set(getConf()); } try { jc.parse(args); } catch (MissingCommandException e) { console.error(e.getMessage()); return 1; } catch (ParameterException e) { help.setProgramName(programName); String cmd = jc.getParsedCommand(); if (args.length == 1) { help.helpCommands.add(cmd); help.run(); return 1; } else { for (String arg : args) { if (HELP_ARGS.contains(arg)) { help.helpCommands.add(cmd); help.run(); return 0; } } } console.error(e.getMessage()); return 1; } help.setProgramName(programName); if (printVersion) { console.info("Kite version \"{}\"", getVersion()); return 0; } if (debug) { org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class); console.setLevel(Level.DEBUG); } String parsed = jc.getParsedCommand(); if (parsed == null) { help.run(); return 1; } else if ("help".equals(parsed)) { return help.run(); } Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0); if (command == null) { help.run(); return 1; } try { if (command instanceof Configurable) { ((Configurable) command).setConf(getConf()); } return command.run(); } catch (IllegalArgumentException e) { if (debug) { console.error("Argument error", e); } else { console.error("Argument error: {}", e.getMessage()); } return 1; } catch (IllegalStateException e) { if (debug) { console.error("State error", e); } else { console.error("State error: {}", e.getMessage()); } return 1; } catch (ValidationException e) { if (debug) { console.error("Validation error", e); } else { console.error("Validation error: {}", e.getMessage()); } return 1; } catch (DatasetNotFoundException e) { if (debug) { console.error("Cannot find dataset", e); } else { console.error(e.getMessage()); } return 1; } catch (DatasetIOException e) { if (debug) { console.error("IO error", e); } else { console.error("IO error: {}", e.getMessage()); } return 1; } catch (Exception e) { if (debug) { console.error("Unknown error", e); } else { console.error("Unknown error: {}", e.getMessage()); } return 1; } } Main(Logger console); @Override int run(String[] args); static void main(String[] args);  }