final String firstLevel = line.words().get(0); final String firstLevel = line.words().get(0); final String secondLevel = line.words().get(1); } 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 Completers.FileNameCompleter fileNameCompleter = new Completers.FileNameCompleter(); final String prevWord = line.words().get(line.wordIndex() - 1);
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null); ParsedLine pl = reader.getParser().parse(line, 0); String[] arguments = pl.words().toArray(new String[0]); CommandLine.run(commands, arguments); } catch (UserInterruptException e) {
public List<String> words() { return line.words(); } public String line() {
@Override public List<String> words() { return JLineShellAutoConfiguration.sanitizeInput(parsedLine.words()); } }
@SuppressWarnings("unchecked") protected void tryCompleteArguments(LineReader reader, ParsedLine line, List<Candidate> candidates) { String command = line.words().get(0); String resolved = environment.resolveCommand(command); Map<String, List<CompletionData>> comp = environment.getCompletions(); if (comp != null) { List<CompletionData> cmd = comp.get(resolved); if (cmd != null) { completeCommandArguments(reader, line, candidates, cmd); } } }
@SuppressWarnings("unchecked") protected void tryCompleteArguments(LineReader reader, ParsedLine line, List<Candidate> candidates) { String command = line.words().get(0); String resolved = environment.resolveCommand(command); Map<String, List<CompletionData>> comp = environment.getCompletions(); if (comp != null) { List<CompletionData> cmd = comp.get(resolved); if (cmd != null) { completeCommandArguments(reader, line, candidates, cmd); } } }
public void execute(PrintStream out, PrintStream err, String command) throws Exception { ParsedLine line = new DefaultParser().parse(command.trim(), 0); execute(out, err, line.words()); }
public void execute(PrintStream out, PrintStream err, String command) throws Exception { ParsedLine line = new DefaultParser().parse(command.trim(), 0); execute(out, err, line.words()); }
@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); }
@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); }
List<? extends CharSequence> args = line.words(); String arg = (args == null || i >= args.size()) ? "" : args.get(i).toString();
String cmd = resolveCommand(pl.words().get(0)); ActionMaskingCallback repl = regexs.get(cmd); if (repl != null) {
String cmd = resolveCommand(pl.words().get(0)); ActionMaskingCallback repl = regexs.get(cmd); if (repl != null) {
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; String key = UUID.randomUUID().toString(); boolean conditionValue = true;
@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 void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { CompletingParsedLine cpl = (line instanceof CompletingParsedLine) ? ((CompletingParsedLine) line) : t -> t; CompletionContext context = new CompletionContext(sanitizeInput(line.words()), line.wordIndex(), line.wordCursor()); List<CompletionProposal> proposals = shell.complete(context); proposals.stream() .map(p -> new Candidate( p.dontQuote() ? p.value() : cpl.emit(p.value()).toString(), p.displayText(), p.category(), p.description(), null, null, true) ) .forEach(candidates::add); }