jline
public class ArgumentCompletor extends Object implements Completor
Example 1: Any argument of the command line can use file completion.
consoleReader.addCompletor (new ArgumentCompletor ( new FileNameCompletor ()))
Example 2: The first argument of the command line can be completed with any of "foo", "bar", or "baz", and remaining arguments can be completed with a file name.
consoleReader.addCompletor (new ArgumentCompletor ( new SimpleCompletor (new String [] { "foo", "bar", "baz"}))); consoleReader.addCompletor (new ArgumentCompletor ( new FileNameCompletor ()));
When the argument index is past the last embedded completors, the last completors is always used. To disable this behavior, have the last completor be a NullCompletor. For example:
consoleReader.addCompletor (new ArgumentCompletor ( new SimpleCompletor (new String [] { "foo", "bar", "baz"}), new SimpleCompletor (new String [] { "xxx", "yyy", "xxx"}), new NullCompletor ));
TODO: handle argument quoting and escape characters
Nested Class Summary | |
---|---|
abstract static class | ArgumentCompletor.AbstractArgumentDelimiter
Abstract implementation of a delimiter that uses the
AbstractArgumentDelimiter method to determine if a particular
character should be used as a delimiter.
|
static interface | ArgumentCompletor.ArgumentDelimiter
The ArgumentDelimiter allows custom
breaking up of a String into individual arguments in
order to dispatch the arguments to the nested Completor.
|
static class | ArgumentCompletor.ArgumentList
The result of a delimited buffer.
|
static class | ArgumentCompletor.WhitespaceArgumentDelimiter
ArgumentDelimiter
implementation that counts all
whitespace (as reported by Character#isWhitespace)
as being a delimiter.
|
Constructor Summary | |
---|---|
ArgumentCompletor(Completor completor)
Constuctor: create a new completor with the default
argument separator of " ".
| |
ArgumentCompletor(List completors)
Constuctor: create a new completor with the default
argument separator of " ".
| |
ArgumentCompletor(Completor[] completors)
Constuctor: create a new completor with the default
argument separator of " ".
| |
ArgumentCompletor(Completor completor, ArgumentCompletor.ArgumentDelimiter delim)
Constuctor: create a new completor with the specified
argument delimiter.
| |
ArgumentCompletor(Completor[] completors, ArgumentCompletor.ArgumentDelimiter delim)
Constuctor: create a new completor with the specified
argument delimiter.
|
Method Summary | |
---|---|
int | complete(String buffer, int cursor, List candidates) |
boolean | getStrict()
Returns whether a completion at argument index N will succees
if all the completions from arguments 0-(N-1) also succeed. |
void | setStrict(boolean strict)
If true, a completion at argument index N will only succeed
if all the completions from 0-(N-1) also succeed. |
Parameters: completor the embedded completor
Parameters: completors the List of completors to use
Parameters: completors the embedded argument completors
Parameters: completor the embedded completor delim the delimiter for parsing arguments
Parameters: completors the embedded completors delim the delimiter for parsing arguments