int argpos = list.getArgumentPosition(); int argIndex = list.getCursorArgumentIndex();
int argpos = list.getArgumentPosition(); int argIndex = list.getCursorArgumentIndex();
/** * Populates the specified list with completion candidates for the specified buffer * based on the command specification that this shell was constructed with. * * @param buffer the command line string * @param cursor the position of the cursor in the command line string * @param candidates the list to populate with completion candidates that would produce * valid options, parameters or subcommands at the cursor position * in the command line * @return the cursor position in the buffer for which the completion will be relative, * or {@code -1} if no completions are found */ //@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { // use the jline internal parser to split the line into tokens ArgumentCompleter.ArgumentList list = new ArgumentCompleter.WhitespaceArgumentDelimiter().delimit(buffer, cursor); // let picocli generate completion candidates for the token where the cursor is at return AutoComplete.complete(spec, list.getArguments(), list.getCursorArgumentIndex(), list.getArgumentPosition(), cursor, candidates); } }
@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { // use the jline internal parser to split the line into tokens ArgumentCompleter.ArgumentList list = new ArgumentCompleter.WhitespaceArgumentDelimiter().delimit(buffer, cursor); // let picocli generate completion candidates for the token where the cursor is at return AutoComplete.complete(commandSpec, list.getArguments(), list.getCursorArgumentIndex(), list.getArgumentPosition(), cursor, candidates); } }