Example #1
0
  private static void printHistory(CommandContext ctx) {

    CommandHistory history = ctx.getHistory();
    List<String> list = history.asList();
    for (String cmd : list) {
      ctx.printLine(cmd);
    }
    ctx.printLine(
        "(The history is currently " + (history.isUseHistory() ? "enabled)" : "disabled)"));
  }
Example #2
0
  @Override
  protected void doHandle(CommandContext ctx) {

    ParsedArguments args = ctx.getParsedArguments();
    if (!args.hasArguments()) {
      printHistory(ctx);
      return;
    }

    if (clear.isPresent(args)) {
      ctx.getHistory().clear();
    } else if (disable.isPresent(args)) {
      ctx.getHistory().setUseHistory(false);
    } else if (enable.isPresent(args)) {
      ctx.getHistory().setUseHistory(true);
    } else {
      ctx.printLine("Unexpected argument '" + ctx.getArgumentsString() + '\'');
    }
  }