@Override public boolean runCmd(String[] args) throws Exception { boolean printUsage = true; if (args.length >= 2) { String command = args[1]; COMMAND c = getHedwigCommands().get(command); if (c != null) { c.printUsage(); printUsage = false; } } if (printUsage) { usage(); } return true; }
protected boolean processCmd(MyCommandOptions co) { String[] args = co.getArgArray(); String cmd = co.getCommand(); if (args.length < 1) { usage(); return false; } if (!getHedwigCommands().containsKey(cmd)) { usage(); return false; } LOG.debug("Processing {}", cmd); MyCommand myCommand = myCommands.get(cmd); if (myCommand == null) { System.err.println("No Command Processor found for command " + cmd); usage(); return false; } long startTime = MathUtils.now(); boolean success = false; try { success = myCommand.runCmd(args); } catch (Exception e) { e.printStackTrace(); success = false; } long elapsedTime = MathUtils.now() - startTime; if (inConsole) { if (success) { System.out.println("Finished " + ((double) elapsedTime / 1000) + " s."); } else { COMMAND c = getHedwigCommands().get(cmd); if (c != null) { c.printUsage(); } } } return success; }