Beispiel #1
0
  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;
  }