@Override public int wordCursor() { return cmdLine.getArgumentPosition(); } @Override
@Override public int wordCursor() { return cmdLine.getArgumentPosition(); } @Override
public int complete(final Session session, final CommandLine commandLine, final List<String> candidates) { // buffer could be null assert candidates != null; String buffer = commandLine.getCursorArgument(); if (buffer == null) { buffer = ""; } else { buffer = buffer.substring(0, commandLine.getArgumentPosition()); } if (!caseSensitive) { buffer = buffer.toLowerCase(); } // KARAF-421, use getStrings() instead strings field. SortedSet<String> matches = getStrings().tailSet(buffer); for (String match : matches) { String s = caseSensitive ? match : match.toLowerCase(); if (!s.startsWith(buffer)) { break; } // noinspection unchecked candidates.add(match + " "); } return candidates.isEmpty() ? -1 : commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } }
public int complete(final Session session, final CommandLine commandLine, final List<String> candidates) { // buffer could be null assert candidates != null; String buffer = commandLine.getCursorArgument(); if (buffer == null) { buffer = ""; } else { buffer = buffer.substring(0, commandLine.getArgumentPosition()); } if (!caseSensitive) { buffer = buffer.toLowerCase(); } // KARAF-421, use getStrings() instead strings field. SortedSet<String> matches = getStrings().tailSet(buffer); for (String match : matches) { String s = caseSensitive ? match : match.toLowerCase(); if (!s.startsWith(buffer)) { break; } // noinspection unchecked candidates.add(match + " "); } return candidates.isEmpty() ? -1 : commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } }
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)); } } } }
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)); } } } }
@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; }
@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; }
private void file(Session session, CommandLine commandLine, List<Candidate> candidates) { String buffer = commandLine.getCursorArgument(); String path = buffer.substring("file:".length(), commandLine.getArgumentPosition());
private void maven(Session session, CommandLine commandLine, List<Candidate> candidates) { String repo = System.getProperty("user.home") + "/.m2/repository"; String buffer = commandLine.getCursorArgument(); String mvn = buffer.substring("mvn:".length(), commandLine.getArgumentPosition());
private void maven(Session session, CommandLine commandLine, List<Candidate> candidates) { String repo = System.getProperty("user.home") + "/.m2/repository"; String buffer = commandLine.getCursorArgument(); String mvn = buffer.substring("mvn:".length(), commandLine.getArgumentPosition());
private void file(Session session, CommandLine commandLine, List<Candidate> candidates) { String buffer = commandLine.getCursorArgument(); String path = buffer.substring("file:".length(), commandLine.getArgumentPosition());
String buffer = commandLine.getCursorArgument().substring(0, commandLine.getArgumentPosition()); if (OS_IS_WINDOWS) { buffer = buffer.replaceAll("/", File.separator);
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String[] args = commandLine.getArguments(); int argIndex = commandLine.getCursorArgumentIndex(); StringsCompleter completer = new StringsCompleter(getNames(session)); if (argIndex == 0) { int res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); if (res > -1) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; } else if (!verifyCompleter(session, completer, args[0])) { return -1; } return 0; }
String buffer = commandLine.getCursorArgument().substring(0, commandLine.getArgumentPosition()); if (OS_IS_WINDOWS) { buffer = buffer.replaceAll("/", File.separator);
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String[] args = commandLine.getArguments(); int argIndex = commandLine.getCursorArgumentIndex(); StringsCompleter completer = new StringsCompleter(getNames(session)); if (argIndex == 0) { int res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); if (res > -1) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; } else if (!verifyCompleter(session, completer, args[0])) { return -1; } return 0; }
public int complete(final Session session, final CommandLine list, final List<String> candidates) { int argpos = list.getArgumentPosition(); int argIndex = list.getCursorArgumentIndex();
public int complete(final Session session, final CommandLine list, final List<String> candidates) { int argpos = list.getArgumentPosition(); int argIndex = list.getCursorArgumentIndex();
StringsCompleter completer = new StringsCompleter(Collections.singletonList(getName())); if (argIndex == 0) { return completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); } else if (!verifyCompleter(session, completer, args[0])) { return -1; int res; if (argIndex < args.length) { res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); } else { res = completer.complete(session, new ArgumentCommandLine("", 0), candidates); return res + (commandLine.getBufferPosition() - commandLine.getArgumentPosition()); } else if (!verifyCompleter(session, completer, args[1])) { return -1;
StringsCompleter completer = new StringsCompleter(Collections.singletonList(getName())); if (argIndex == 0) { return completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); } else if (!verifyCompleter(session, completer, args[0])) { return -1; int res; if (argIndex < args.length) { res = completer.complete(session, new ArgumentCommandLine(args[argIndex], commandLine.getArgumentPosition()), candidates); } else { res = completer.complete(session, new ArgumentCommandLine("", 0), candidates); return res + (commandLine.getBufferPosition() - commandLine.getArgumentPosition()); } else if (!verifyCompleter(session, completer, args[1])) { return -1;