addCandidates(SessionVariable.getAllVariableNames(), candidates); } else if (line.wordIndex() == 3) { final String currWord = line.word(); final String prevWord = line.words().get(line.wordIndex() - 1); if (FILE_COMPLETION_VARS.contains(prevWord)) { final String currWord = line.word(); final String prevWord = line.words().get(line.wordIndex() - 1);
@Override public String getCursorArgument() { return line.word(); }
@Override public synchronized void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { List<String> words = line.words().subList(0, line.wordIndex()); this.reader.set(reader); Set<String> next = matcher.matchPartial(words); for (String n : next) { completers.apply(n).complete(reader, new ArgumentLine(line.word(), line.wordCursor()), candidates); } this.reader.set(null); }
query.append('\n'); query.append(line); } else if ("load".equals(pl.word())) { if (pl.words().size() == 2 || pl.words().size() == 3 || pl.words().size() == 4) { String[] splits = line.split("\\s"); } else if ("get".equals(pl.word())) { if (pl.words().size() == 2) { String uri = pl.words().get(1); } else if ("query".equals(pl.word())) { query = new StringBuffer(line); query.delete(0, 6); querying = true; } else if ("remove".equals(pl.word())) { if (pl.words().size() == 2) { String uri = pl.words().get(1); } else if ("cls".equals(pl.word())) { terminal.puts(Capability.clear_screen); terminal.flush(); } else if ("help".equals(pl.word())) { usage(terminal);
assert candidates != null; String buffer = commandLine.word().substring(0, commandLine.wordCursor());
@Override public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { if (line.wordIndex() == 0) { makeCommandCandidates(line.word(), candidates); makeTransletCandidates(line.word(), candidates); } else if (line.wordIndex() > 0) { String cmd = line.words().get(0); makeOptionCandidates(cmd, line.word(), candidates); } }
@Override public synchronized void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { List<String> words = line.words().subList(0, line.wordIndex()); this.reader.set(reader); Set<String> next = matcher.matchPartial(words); for (String n : next) { completers.apply(n).complete(reader, new ArgumentLine(line.word(), line.wordCursor()), candidates); } this.reader.set(null); }
assert candidates != null; String buffer = commandLine.word().substring(0, commandLine.wordCursor());
@Override public String getCursorArgument() { return line.word(); }
@SuppressWarnings("unchecked") protected void completeCommandArguments(LineReader reader, ParsedLine line, List<Candidate> candidates, List<CompletionData> completions) { for (CompletionData completion : completions) { boolean isOption = line.word().startsWith("-"); String prevOption = line.wordIndex() >= 2 && line.words().get(line.wordIndex() - 1).startsWith("-") ? line.words().get(line.wordIndex() - 1) : null;
assert candidates != null; String buffer = commandLine.word().substring(0, commandLine.wordCursor());
public String word() { return line.word(); } public int wordCursor() {
@SuppressWarnings("unchecked") protected void completeCommandArguments(LineReader reader, ParsedLine line, List<Candidate> candidates, List<CompletionData> completions) { for (CompletionData completion : completions) { boolean isOption = line.word().startsWith("-"); String prevOption = line.wordIndex() >= 2 && line.words().get(line.wordIndex() - 1).startsWith("-") ? line.words().get(line.wordIndex() - 1) : null;
@Override public void complete(LineReader lineReader, ParsedLine parsedLine, List<Candidate> candidates) { String buffer = parsedLine.word().trim(); if (Strings.isNullOrEmpty(buffer)) { candidates.addAll(_commandStrs.stream().map(Candidate::new).collect(Collectors.toList())); } else { for (String match : _commandStrs.tailSet(buffer)) { if (!match.startsWith(buffer)) { break; } candidates.add(new Candidate(match)); } } // if the match was unique and the complete command was specified, print the command usage if (candidates.size() == 1 && candidates.get(0).displ().equals(buffer)) { candidates.clear(); candidates.add( new Candidate( " " + Command.getUsageMap().get(Command.getNameMap().get(buffer)).getFirst())); } } }