Package org.jline.builtins
Class Completers.OptDesc
java.lang.Object
org.jline.builtins.Completers.OptDesc
- Enclosing class:
Completers
Describes a command-line option for completion.
This class holds information about command options, including short and long forms, descriptions, and value completers for options that take arguments.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
OptDesc()
Protected default constructor for subclasses.Command option description.Command option description.Command option description.Command option description. -
Method Summary
Modifier and TypeMethodDescriptionprotected static List
<Completers.OptDesc> Compiles a list of OptDesc objects from option values and options.protected void
completeOption
(LineReader reader, ParsedLine commandLine, List<Candidate> candidates, boolean longOpt) Completes an option based on whether it's a short or long option.protected boolean
completeValue
(LineReader reader, ParsedLine commandLine, List<Candidate> candidates, String curBuf, String partialValue) Completes the value for an option.Gets the description of the option.protected boolean
hasValue()
Determines if this option takes a value.Gets the long form of the option.protected boolean
Determines if this option matches the specified option string.void
setValueCompleter
(Completer valueCompleter) Sets the value completer for this option.Gets the short form of the option.protected boolean
startsWith
(String option) Determines if this option starts with the specified prefix.protected Completer
Gets the value completer for this option.
-
Constructor Details
-
OptDesc
Command option description. If option does not have short/long option assign to it null value. If option does not have value set valueCompleter = NullCompleter.INSTANCE- Parameters:
shortOption
- short optionlongOption
- long optiondescription
- short option descriptionvalueCompleter
- option value completer
-
OptDesc
Command option description. If option does not have short/long option assign to it null value. If option does not have value set valueCompleter = NullCompleter.INSTANCE- Parameters:
shortOption
- short optionlongOption
- long optionvalueCompleter
- option value completer
-
OptDesc
Command option description. If option does not have short/long option assign to it null value.- Parameters:
shortOption
- short optionlongOption
- long optiondescription
- short option description
-
OptDesc
Command option description. If option does not have short/long option assign to it null value.- Parameters:
shortOption
- short optionlongOption
- long option
-
OptDesc
protected OptDesc()Protected default constructor for subclasses.
-
-
Method Details
-
compile
protected static List<Completers.OptDesc> compile(Map<String, List<String>> optionValues, Collection<String> options) Compiles a list of OptDesc objects from option values and options.Creates OptDesc objects for both options with values and options without values.
- Parameters:
optionValues
- a map of option names to their possible valuesoptions
- a collection of option names that don't take values- Returns:
- a list of OptDesc objects
-
setValueCompleter
Sets the value completer for this option.- Parameters:
valueCompleter
- the completer for option values
-
longOption
Gets the long form of the option.- Returns:
- the long option string, or null if not set
-
shortOption
Gets the short form of the option.- Returns:
- the short option string, or null if not set
-
description
Gets the description of the option.- Returns:
- the option description, or null if not set
-
hasValue
protected boolean hasValue()Determines if this option takes a value.- Returns:
- true if the option takes a value, false otherwise
-
valueCompleter
Gets the value completer for this option.- Returns:
- the value completer, or null if not set
-
completeOption
protected void completeOption(LineReader reader, ParsedLine commandLine, List<Candidate> candidates, boolean longOpt) Completes an option based on whether it's a short or long option.Adds appropriate candidates for the option based on its type and whether it takes a value.
- Parameters:
reader
- the line readercommandLine
- the parsed command linecandidates
- the list to add completion candidates tolongOpt
- true if completing long options, false for short options
-
completeValue
protected boolean completeValue(LineReader reader, ParsedLine commandLine, List<Candidate> candidates, String curBuf, String partialValue) Completes the value for an option.Uses the option's value completer to generate completion candidates for the option value.
- Parameters:
reader
- the line readercommandLine
- the parsed command linecandidates
- the list to add completion candidates tocurBuf
- the current buffer up to the cursorpartialValue
- the partial value to complete- Returns:
- true if any candidates were added, false otherwise
-
match
Determines if this option matches the specified option string.- Parameters:
option
- the option string to check- Returns:
- true if this option matches the specified string, false otherwise
-
startsWith
Determines if this option starts with the specified prefix.- Parameters:
option
- the prefix to check- Returns:
- true if this option starts with the specified prefix, false otherwise
-