public boolean config()

in shell/src/main/java/org/apache/accumulo/shell/Shell.java [303:455]


  public boolean config(String... args) throws IOException {
    if (this.terminal == null) {
      this.terminal =
          TerminalBuilder.builder().jansi(false).systemOutput(SystemOutput.SysOut).build();
    }
    if (this.reader == null) {
      this.reader = LineReaderBuilder.builder().terminal(this.terminal).build();
    }
    this.writer = this.terminal.writer();

    ShellOptionsJC options = new ShellOptionsJC();
    JCommander jc = new JCommander();

    jc.setProgramName("accumulo shell");
    jc.addObject(options);
    try {
      jc.parse(args);
    } catch (ParameterException e) {
      jc.usage();
      exitCode = 1;
      return false;
    }

    if (options.isHelpEnabled()) {
      jc.usage();
      // Not an error
      exitCode = 0;
      return false;
    }

    if (options.getUnrecognizedOptions() != null) {
      logError("Unrecognized Options: " + options.getUnrecognizedOptions());
      jc.usage();
      exitCode = 1;
      return false;
    }

    authTimeout = TimeUnit.MINUTES.toNanos(options.getAuthTimeout());
    disableAuthTimeout = options.isAuthTimeoutDisabled();

    clientProperties = options.getClientProperties();
    if (ClientProperty.SASL_ENABLED.getBoolean(clientProperties)) {
      log.debug("SASL is enabled, disabling authorization timeout");
      disableAuthTimeout = true;
    }

    tabCompletion = !options.isTabCompletionDisabled();
    this.setTableName("");

    if (accumuloClient == null) {
      if (ClientProperty.INSTANCE_ZOOKEEPERS.isEmpty(clientProperties)) {
        throw new IllegalArgumentException("ZooKeepers must be set using -z or -zh on command line"
            + " or in accumulo-client.properties");
      }
      if (ClientProperty.INSTANCE_NAME.isEmpty(clientProperties)) {
        throw new IllegalArgumentException("Instance name must be set using -z or -zi on command "
            + "line or in accumulo-client.properties");
      }
      final String principal;
      try {
        principal = options.getUsername();
      } catch (Exception e) {
        logError(e.getMessage());
        exitCode = 1;
        return false;
      }
      String authenticationString = options.getPassword();
      final AuthenticationToken token =
          getAuthenticationToken(principal, authenticationString, "Password: ");
      try {
        this.setTableName("");
        accumuloClient = Accumulo.newClient().from(clientProperties).as(principal, token).build();
        authenticateUser(accumuloClient, token);
        context = (ClientContext) accumuloClient;
      } catch (Exception e) {
        printException(e);
        exitCode = 1;
        return false;
      }
    }

    canPaginate = terminal.getSize().getRows() > 0;

    // decide whether to execute commands from a file and quit
    if (options.getExecFile() != null) {
      execFile = options.getExecFile();
      verbose = false;
    } else if (options.getExecFileVerbose() != null) {
      execFile = options.getExecFileVerbose();
      verbose = true;
    }
    execCommand = options.getExecCommand();
    if (execCommand != null) {
      verbose = false;
    }

    rootToken = new Token();

    Command[] dataCommands = {new DeleteCommand(), new DeleteManyCommand(), new DeleteRowsCommand(),
        new EGrepCommand(), new FormatterCommand(), new GrepCommand(), new ImportDirectoryCommand(),
        new InsertCommand(), new MaxRowCommand(), new ScanCommand()};
    Command[] debuggingCommands =
        {new ClasspathCommand(), new ListScansCommand(), new ListCompactionsCommand(),
            new TraceCommand(), new PingCommand(), new ListBulkCommand(), new ListTabletsCommand()};
    Command[] execCommands = {new ExecfileCommand(), new HistoryCommand(), new ExtensionCommand()};
    Command[] exitCommands = {new ByeCommand(), new ExitCommand(), new QuitCommand()};
    Command[] helpCommands =
        {new AboutCommand(), new HelpCommand(), new InfoCommand(), new QuestionCommand()};
    Command[] iteratorCommands =
        {new DeleteIterCommand(), new ListIterCommand(), new SetIterCommand(),
            new SetShellIterCommand(), new ListShellIterCommand(), new DeleteShellIterCommand()};
    Command[] otherCommands = {new HiddenCommand()};
    Command[] permissionsCommands = {new GrantCommand(), new RevokeCommand(),
        new SystemPermissionsCommand(), new TablePermissionsCommand(), new UserPermissionsCommand(),
        new NamespacePermissionsCommand()};
    Command[] stateCommands =
        {new AuthenticateCommand(), new ClsCommand(), new ClearCommand(), new NoTableCommand(),
            new SleepCommand(), new TableCommand(), new UserCommand(), new WhoAmICommand()};
    Command[] tableCommands = {new CloneTableCommand(), new ConfigCommand(),
        new CreateTableCommand(), new DeleteTableCommand(), new DropTableCommand(), new DUCommand(),
        new ExportTableCommand(), new ImportTableCommand(), new OfflineCommand(),
        new SetAvailabilityCommand(), new GetAvailabilityCommand(), new OnlineCommand(),
        new RenameTableCommand(), new TablesCommand(), new NamespacesCommand(),
        new CreateNamespaceCommand(), new DeleteNamespaceCommand(), new RenameNamespaceCommand(),
        new SummariesCommand()};
    Command[] tableControlCommands = {new AddSplitsCommand(), new CompactCommand(),
        new ConstraintCommand(), new FlushCommand(), new GetGroupsCommand(), new GetSplitsCommand(),
        new MergeCommand(), new SetGroupsCommand()};
    Command[] userCommands = {new AddAuthsCommand(), new CreateUserCommand(),
        new DeleteUserCommand(), new DropUserCommand(), new GetAuthsCommand(), new PasswdCommand(),
        new SetAuthsCommand(), new UsersCommand(), new DeleteAuthsCommand()};
    commandGrouping.put("-- Writing, Reading, and Removing Data --", dataCommands);
    commandGrouping.put("-- Debugging Commands -------------------", debuggingCommands);
    commandGrouping.put("-- Shell Execution Commands -------------", execCommands);
    commandGrouping.put("-- Exiting Commands ---------------------", exitCommands);
    commandGrouping.put("-- Help Commands ------------------------", helpCommands);
    commandGrouping.put("-- Iterator Configuration ---------------", iteratorCommands);
    commandGrouping.put("-- Permissions Administration Commands --", permissionsCommands);
    commandGrouping.put("-- Shell State Commands -----------------", stateCommands);
    commandGrouping.put("-- Table Administration Commands --------", tableCommands);
    commandGrouping.put("-- Table Control Commands ---------------", tableControlCommands);
    commandGrouping.put("-- User Administration Commands ---------", userCommands);

    for (Command[] cmds : commandGrouping.values()) {
      for (Command cmd : cmds) {
        commandFactory.put(cmd.getName(), cmd);
      }
    }
    for (Command cmd : otherCommands) {
      commandFactory.put(cmd.getName(), cmd);
    }
    return true;
  }