protected boolean verifyCompleter(Session session, Completer completer, String argument) { List<String> candidates = new ArrayList<>(); return completer.complete(session, new ArgumentCommandLine(argument, argument.length()), candidates) != -1 && !candidates.isEmpty(); } };
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { // buffer could be null assert candidates != null; for (Completer completer : completers) { completer.completeCandidates(session, commandLine, candidates); } }
protected boolean verifyCompleter(Session session, Completer completer, String argument) { List<String> candidates = new ArrayList<>(); return completer.complete(session, new ArgumentCommandLine(argument, argument.length()), candidates) != -1 && !candidates.isEmpty(); } };
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { // buffer could be null assert candidates != null; for (Completer completer : completers) { completer.completeCandidates(session, commandLine, candidates); } }
private boolean verifyCompleter(Session session, Completer completer, String argument) { List<String> candidates = new ArrayList<>(); return completer.complete(session, new ArgumentCommandLine(argument, argument.length()), candidates) != -1 && !candidates.isEmpty(); }
protected boolean verifyCompleter(Session session, Completer completer, String argument) { List<Candidate> candidates = new ArrayList<>(); completer.completeCandidates(session, new ArgumentCommandLine(argument, argument.length()), candidates); return !candidates.isEmpty(); }
private boolean verifyCompleter(Session session, Completer completer, String argument) { List<String> candidates = new ArrayList<>(); return completer.complete(session, new ArgumentCommandLine(argument, argument.length()), candidates) != -1 && !candidates.isEmpty(); }
protected boolean verifyCompleter(Session session, Completer completer, String argument) { List<Candidate> candidates = new ArrayList<>(); completer.completeCandidates(session, new ArgumentCommandLine(argument, argument.length()), candidates); return !candidates.isEmpty(); }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
default void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { List<String> strings = new ArrayList<>(); int idx = complete(session, commandLine, strings); String word = ""; if (idx > commandLine.getBufferPosition() - commandLine.getArgumentPosition()) { word = commandLine.getBuffer().substring(commandLine.getBufferPosition() - commandLine.getArgumentPosition(), idx); } for (String string : strings) { String str = word + string; if (str.endsWith(" ")) { candidates.add(new Candidate(str.substring(0, str.length() - 1), true)); } else { candidates.add(new Candidate(word + string, false)); } } } }
completers.add(new StringsCompleter(Collections.singletonList("exit"))); completers.forEach(c -> c.completeCandidates(session, commandLine, candidates)); return; completers.forEach(c -> c.completeCandidates(session, commandLine, candidates)); if (!candidates.isEmpty()) { return; compl.add(aliasesCompleter); compl.addAll(allCompleters[0].values()); compl.forEach(c -> c.completeCandidates(session, commandLine, candidates)); return; compl.add(aliasesCompleter); compl.addAll(allCompleters[0].values()); compl.forEach(c -> c.completeCandidates(session, commandLine, candidates));
default void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { List<String> strings = new ArrayList<>(); int idx = complete(session, commandLine, strings); String word = ""; if (idx > commandLine.getBufferPosition() - commandLine.getArgumentPosition()) { word = commandLine.getBuffer().substring(commandLine.getBufferPosition() - commandLine.getArgumentPosition(), idx); } for (String string : strings) { String str = word + string; if (str.endsWith(" ")) { candidates.add(new Candidate(str.substring(0, str.length() - 1), true)); } else { candidates.add(new Candidate(word + string, false)); } } } }
completers.add(new StringsCompleter(Collections.singletonList("exit"))); completers.forEach(c -> c.completeCandidates(session, commandLine, candidates)); return; completers.forEach(c -> c.completeCandidates(session, commandLine, candidates)); if (!candidates.isEmpty()) { return; compl.add(aliasesCompleter); compl.addAll(allCompleters[0].values()); compl.forEach(c -> c.completeCandidates(session, commandLine, candidates)); return; compl.add(aliasesCompleter); compl.addAll(allCompleters[0].values()); compl.forEach(c -> c.completeCandidates(session, commandLine, candidates));
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
comp.completeCandidates(session, list, candidates);
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
comp.completeCandidates(session, list, candidates);