Package org.jline.builtins
Class Completers.OptionCompleter
java.lang.Object
org.jline.builtins.Completers.OptionCompleter
- All Implemented Interfaces:
Completer
- Enclosing class:
Completers
A completer for command options and arguments.
This completer handles completion for command options (both short and long forms) and their values, as well as command arguments. It's designed to be used as part of an ArgumentCompleter for a complete command-line interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of completers for command argumentsprivate Function<String, Collection<Completers.OptDesc>> Function to get option descriptions for a commandprivate Collection<Completers.OptDesc> Collection of option descriptionsprivate intThe position of this completer in the argument list -
Constructor Summary
ConstructorsConstructorDescriptionOptionCompleter(Collection<Completers.OptDesc> options, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(List<Completer> completers, Collection<Completers.OptDesc> options, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(List<Completer> completers, Function<String, Collection<Completers.OptDesc>> commandOptions, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(List<Completer> completers, Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(Completer completer, Collection<Completers.OptDesc> options, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(Completer completer, Function<String, Collection<Completers.OptDesc>> commandOptions, int startPos) OptionCompleter completes command options and parameters.OptionCompleter(Completer completer, Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete(LineReader reader, ParsedLine commandLine, List<Candidate> candidates) Completes command options and arguments.private Completers.OptDescfindOptDesc(String command, String opt) Finds an option description for a command and option string.private Completers.OptDescfindOptDesc(Collection<Completers.OptDesc> optDescs, String opt) Finds an option description in a collection of option descriptions.private CompleterlongOptionValueCompleter(String command, String opt) Gets the value completer for a long option.voidsetStartPos(int startPos) Sets the start position of this completer in the argument list.private CompletershortOptionValueCompleter(String command, String opt) Gets the value completer for a short option.
-
Field Details
-
commandOptions
Function to get option descriptions for a command -
options
Collection of option descriptions -
argsCompleters
List of completers for command arguments -
startPos
private int startPosThe position of this completer in the argument list
-
-
Constructor Details
-
OptionCompleter
public OptionCompleter(Completer completer, Function<String, Collection<Completers.OptDesc>> commandOptions, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completer- command parameter completercommandOptions- command options descriptionsstartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
public OptionCompleter(List<Completer> completers, Function<String, Collection<Completers.OptDesc>> commandOptions, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completers- command parameters completerscommandOptions- command options descriptionsstartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
public OptionCompleter(List<Completer> completers, Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completers- command parameters completersoptionValues- command value options as map key and its possible values as map valueoptions- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
public OptionCompleter(Completer completer, Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completer- command parameter completeroptionValues- command value options as map key and its possible values as map valueoptions- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
public OptionCompleter(Map<String, List<String>> optionValues, Collection<String> options, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
optionValues- command value options as map key and its possible values as map valueoptions- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completer- command parameter completeroptions- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
public OptionCompleter(List<Completer> completers, Collection<Completers.OptDesc> options, int startPos) OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
completers- command parameters completersoptions- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
OptionCompleter
OptionCompleter completes command options and parameters. OptionCompleter should be used as an argument of ArgumentCompleter- Parameters:
options- command options that do not have valuestartPos- OptionCompleter position in ArgumentCompleter parameters
-
-
Method Details
-
setStartPos
public void setStartPos(int startPos) Sets the start position of this completer in the argument list.- Parameters:
startPos- the position of this completer
-
complete
Completes command options and arguments.This method handles completion for:
- Command options (both short and long forms)
- Option values (for options that take values)
- Command arguments (using the appropriate argument completer)
-
longOptionValueCompleter
Gets the value completer for a long option.- Parameters:
command- the command nameopt- the option string- Returns:
- the value completer for the option, or null if the option doesn't take a value
-
shortOptionValueCompleter
Gets the value completer for a short option.Handles both single short options (-a) and combined short options (-abc).
- Parameters:
command- the command nameopt- the option string- Returns:
- the value completer for the option, or null if the option doesn't take a value
-
findOptDesc
Finds an option description for a command and option string.- Parameters:
command- the command nameopt- the option string- Returns:
- the option description
-
findOptDesc
Finds an option description in a collection of option descriptions.- Parameters:
optDescs- the collection of option descriptionsopt- the option string- Returns:
- the matching option description, or a new empty OptDesc if not found
-