Package org.jline.builtins
Class Completers.OptDesc
- java.lang.Object
-
- org.jline.builtins.Completers.OptDesc
-
- Enclosing class:
- Completers
public static class Completers.OptDesc extends java.lang.ObjectDescribes 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
Constructors Modifier Constructor Description protectedOptDesc()Protected default constructor for subclasses.OptDesc(java.lang.String shortOption, java.lang.String longOption)Command option description.OptDesc(java.lang.String shortOption, java.lang.String longOption, java.lang.String description)Command option description.OptDesc(java.lang.String shortOption, java.lang.String longOption, java.lang.String description, Completer valueCompleter)Command option description.OptDesc(java.lang.String shortOption, java.lang.String longOption, Completer valueCompleter)Command option description.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.List<Completers.OptDesc>compile(java.util.Map<java.lang.String,java.util.List<java.lang.String>> optionValues, java.util.Collection<java.lang.String> options)Compiles a list of OptDesc objects from option values and options.protected voidcompleteOption(LineReader reader, ParsedLine commandLine, java.util.List<Candidate> candidates, boolean longOpt)Completes an option based on whether it's a short or long option.protected booleancompleteValue(LineReader reader, ParsedLine commandLine, java.util.List<Candidate> candidates, java.lang.String curBuf, java.lang.String partialValue)Completes the value for an option.java.lang.Stringdescription()Gets the description of the option.protected booleanhasValue()Determines if this option takes a value.java.lang.StringlongOption()Gets the long form of the option.protected booleanmatch(java.lang.String option)Determines if this option matches the specified option string.voidsetValueCompleter(Completer valueCompleter)Sets the value completer for this option.java.lang.StringshortOption()Gets the short form of the option.protected booleanstartsWith(java.lang.String option)Determines if this option starts with the specified prefix.protected CompletervalueCompleter()Gets the value completer for this option.
-
-
-
Constructor Detail
-
OptDesc
public OptDesc(java.lang.String shortOption, java.lang.String longOption, java.lang.String description, Completer valueCompleter)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
public OptDesc(java.lang.String shortOption, java.lang.String longOption, Completer valueCompleter)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
public OptDesc(java.lang.String shortOption, java.lang.String longOption, java.lang.String description)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
public OptDesc(java.lang.String shortOption, java.lang.String longOption)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 Detail
-
compile
protected static java.util.List<Completers.OptDesc> compile(java.util.Map<java.lang.String,java.util.List<java.lang.String>> optionValues, java.util.Collection<java.lang.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
public void setValueCompleter(Completer valueCompleter)
Sets the value completer for this option.- Parameters:
valueCompleter- the completer for option values
-
longOption
public java.lang.String longOption()
Gets the long form of the option.- Returns:
- the long option string, or null if not set
-
shortOption
public java.lang.String shortOption()
Gets the short form of the option.- Returns:
- the short option string, or null if not set
-
description
public java.lang.String 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
protected Completer 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, java.util.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, java.util.List<Candidate> candidates, java.lang.String curBuf, java.lang.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
protected boolean match(java.lang.String option)
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
protected boolean startsWith(java.lang.String option)
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
-
-