org.jline.reader.impl.completer.NullCompleter Java Examples
The following examples show how to use
org.jline.reader.impl.completer.NullCompleter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Console.java From xraft with MIT License | 6 votes |
public Console(Map<NodeId, Address> serverMap) { commandMap = buildCommandMap(Arrays.asList( new ExitCommand(), new ClientAddServerCommand(), new ClientRemoveServerCommand(), new ClientListServerCommand(), new ClientGetLeaderCommand(), new ClientSetLeaderCommand(), new RaftAddNodeCommand(), new RaftRemoveNodeCommand(), new KVStoreGetCommand(), new KVStoreSetCommand() )); commandContext = new CommandContext(serverMap); ArgumentCompleter completer = new ArgumentCompleter( new StringsCompleter(commandMap.keySet()), new NullCompleter() ); reader = LineReaderBuilder.builder() .completer(completer) .build(); }
Example #2
Source File: SqlLineCommandCompleter.java From sqlline with BSD 3-Clause "New" or "Revised" License | 5 votes |
SqlLineCommandCompleter(SqlLine sqlLine) { super(new LinkedList<>()); List<Completer> completers = new LinkedList<>(); for (CommandHandler commandHandler : sqlLine.getCommandHandlers()) { for (String cmd : commandHandler.getNames()) { List<Completer> compl = new LinkedList<>(); final List<Completer> parameterCompleters = commandHandler.getParameterCompleters(); if (parameterCompleters.size() == 1 && parameterCompleters.iterator().next() instanceof Completers.RegexCompleter) { completers.add(parameterCompleters.iterator().next()); } else { final String commandName = SqlLine.COMMAND_PREFIX + cmd; final String helpText = commandHandler.getHelpText(); final int firstEndOfLineIndex = helpText.indexOf('\n'); compl.add( new StringsCompleter( new SqlLineCandidate(sqlLine, AttributedString.stripAnsi(commandName), commandName, sqlLine.loc("command-name"), firstEndOfLineIndex == -1 ? helpText : helpText.substring(0, firstEndOfLineIndex), // there could be whatever else instead helpText // which is the same for commands with all theirs aliases null, helpText, true))); compl.addAll(parameterCompleters); compl.add(new NullCompleter()); // last param no complete completers.add(new ArgumentCompleter(compl)); } } } getCompleters().addAll(completers); }
Example #3
Source File: AbstractCommandHandler.java From sqlline with BSD 3-Clause "New" or "Revised" License | 5 votes |
public AbstractCommandHandler(SqlLine sqlLine, String[] names, String helpText, List<Completer> completers) { this.sqlLine = sqlLine; name = names[0]; this.names = Arrays.asList(names); this.helpText = helpText; if (completers == null || completers.size() == 0) { this.parameterCompleters = Collections.singletonList(new NullCompleter()); } else { this.parameterCompleters = new ArrayList<>(completers); } }
Example #4
Source File: Client.java From batfish with Apache License 2.0 | 4 votes |
public Client(Settings settings) { _additionalBatfishOptions = new HashMap<>(); _bfq = new TreeMap<>(); _settings = settings; switch (_settings.getRunMode()) { case batch: if (_settings.getBatchCommandFile() == null) { System.err.println( "org.batfish.client: Command file not specified while running in batch mode."); System.err.printf( "Use '-%s <cmdfile>' if you want batch mode, or '-%s interactive' if you want " + "interactive mode\n", Settings.ARG_COMMAND_FILE, Settings.ARG_RUN_MODE); System.exit(1); } _logger = new BatfishLogger(_settings.getLogLevel(), false, _settings.getLogFile()); break; case interactive: System.err.println( "This is not a supported client for Batfish. Please use pybatfish following the " + "instructions in the README: https://github.com/batfish/batfish/#how-do-i-get-started"); try { _reader = LineReaderBuilder.builder() .terminal(TerminalBuilder.builder().build()) .completer(new ArgumentCompleter(new CommandCompleter(), new NullCompleter())) .build(); Path historyPath = Paths.get(System.getenv(ENV_HOME), HISTORY_FILE); historyPath.toFile().createNewFile(); _reader.setVariable(LineReader.HISTORY_FILE, historyPath.toAbsolutePath().toString()); _reader.unsetOpt(Option.INSERT_TAB); // supports completion with nothing entered @SuppressWarnings("PMD.CloseResource") // PMD does not understand things closed later. PrintWriter pWriter = new PrintWriter(_reader.getTerminal().output(), true); @SuppressWarnings("PMD.CloseResource") // PMD does not understand things closed later. OutputStream os = new WriterOutputStream(pWriter, StandardCharsets.UTF_8); @SuppressWarnings("PMD.CloseResource") // PMD does not understand things closed later. PrintStream ps = new PrintStream(os, true); _logger = new BatfishLogger(_settings.getLogLevel(), false, ps); } catch (Exception e) { System.err.printf("Could not initialize client: %s\n", e.getMessage()); e.printStackTrace(); } break; default: System.err.println("org.batfish.client: Unknown run mode."); System.exit(1); } }