Package org.jline.console
Class CmdDesc
java.lang.Object
org.jline.console.CmdDesc
Represents a command description used for generating command help and documentation.
This class stores information about a command, including its main description,
argument descriptions, and option descriptions. It is used by the JLine Widgets
framework to display command help in the terminal.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe descriptions of the command's argumentsprivate booleanWhether this is a command (as opposed to a method or syntax)private intIndex of the error in the command, or -1 if no errorprivate PatternPattern used to identify errors in the commandprivate booleanWhether the command should be highlightedprivate List<AttributedString> The main description of the commandprivate TreeMap<String, List<AttributedString>> The descriptions of the command's optionsprivate booleanWhether this is a subcommandprivate booleanWhether the command is valid -
Constructor Summary
ConstructorsConstructorDescriptionCmdDesc()Creates a new command description that is not a command.CmdDesc(boolean valid) Creates a new command description with the specified validity.Creates a new command description with the specified argument descriptions.Creates a new command description with the specified argument and option descriptions.CmdDesc(List<AttributedString> mainDesc, List<ArgDesc> argsDesc, Map<String, List<AttributedString>> optsDesc) Creates a new command description with the specified main description, argument descriptions, and option descriptions. -
Method Summary
Modifier and TypeMethodDescriptionReturns the descriptions of the command's arguments.intReturns the index of the error in the command.Returns the pattern used to identify errors in the command.Returns the main description of the command.Returns the descriptions of the command's options.booleanReturns whether this is a command (as opposed to a method or syntax).booleanReturns whether the command should be highlighted.booleanReturns whether this is a subcommand.booleanisValid()Returns whether the command is valid.mainDesc(List<AttributedString> mainDesc) Sets the main description of the command and returns this command description.optionDescription(String key) Returns the description of the specified option.booleanoptionWithValue(String option) Returns whether the specified option takes a value.voidsetErrorIndex(int errorIndex) Sets the index of the error in the command.voidsetErrorPattern(Pattern errorPattern) Sets the pattern used to identify errors in the command.voidsetHighlighted(boolean highlighted) Sets whether the command should be highlighted.voidsetMainDesc(List<AttributedString> mainDesc) Sets the main description of the command.voidsetSubcommand(boolean subcommand) Sets whether this is a subcommand.
-
Field Details
-
mainDesc
The main description of the command -
argsDesc
The descriptions of the command's arguments -
optsDesc
The descriptions of the command's options -
errorPattern
Pattern used to identify errors in the command -
errorIndex
private int errorIndexIndex of the error in the command, or -1 if no error -
valid
private boolean validWhether the command is valid -
command
private boolean commandWhether this is a command (as opposed to a method or syntax) -
subcommand
private boolean subcommandWhether this is a subcommand -
highlighted
private boolean highlightedWhether the command should be highlighted
-
-
Constructor Details
-
CmdDesc
public CmdDesc()Creates a new command description that is not a command. -
CmdDesc
public CmdDesc(boolean valid) Creates a new command description with the specified validity.- Parameters:
valid- whether the command is valid
-
CmdDesc
Creates a new command description with the specified argument descriptions.- Parameters:
argsDesc- the descriptions of the command's arguments
-
CmdDesc
Creates a new command description with the specified argument and option descriptions.- Parameters:
argsDesc- the descriptions of the command's argumentsoptsDesc- the descriptions of the command's options
-
CmdDesc
public CmdDesc(List<AttributedString> mainDesc, List<ArgDesc> argsDesc, Map<String, List<AttributedString>> optsDesc) Creates a new command description with the specified main description, argument descriptions, and option descriptions.- Parameters:
mainDesc- the main description of the commandargsDesc- the descriptions of the command's argumentsoptsDesc- the descriptions of the command's options
-
-
Method Details
-
isValid
public boolean isValid()Returns whether the command is valid.- Returns:
- true if the command is valid, false otherwise
-
isCommand
public boolean isCommand()Returns whether this is a command (as opposed to a method or syntax).- Returns:
- true if this is a command, false otherwise
-
setSubcommand
public void setSubcommand(boolean subcommand) Sets whether this is a subcommand.- Parameters:
subcommand- true if this is a subcommand, false otherwise
-
isSubcommand
public boolean isSubcommand()Returns whether this is a subcommand.- Returns:
- true if this is a subcommand, false otherwise
-
setHighlighted
public void setHighlighted(boolean highlighted) Sets whether the command should be highlighted.- Parameters:
highlighted- true if the command should be highlighted, false otherwise
-
isHighlighted
public boolean isHighlighted()Returns whether the command should be highlighted.- Returns:
- true if the command should be highlighted, false otherwise
-
mainDesc
Sets the main description of the command and returns this command description.- Parameters:
mainDesc- the main description of the command- Returns:
- this command description
-
setMainDesc
Sets the main description of the command.- Parameters:
mainDesc- the main description of the command
-
getMainDesc
Returns the main description of the command.- Returns:
- the main description of the command
-
getOptsDesc
Returns the descriptions of the command's options.- Returns:
- the descriptions of the command's options
-
setErrorPattern
Sets the pattern used to identify errors in the command.- Parameters:
errorPattern- the pattern used to identify errors
-
getErrorPattern
Returns the pattern used to identify errors in the command.- Returns:
- the pattern used to identify errors
-
setErrorIndex
public void setErrorIndex(int errorIndex) Sets the index of the error in the command.- Parameters:
errorIndex- the index of the error, or -1 if no error
-
getErrorIndex
public int getErrorIndex()Returns the index of the error in the command.- Returns:
- the index of the error, or -1 if no error
-
getArgsDesc
Returns the descriptions of the command's arguments.- Returns:
- the descriptions of the command's arguments
-
optionWithValue
Returns whether the specified option takes a value.- Parameters:
option- the option to check- Returns:
- true if the option takes a value, false otherwise
-
optionDescription
Returns the description of the specified option.- Parameters:
key- the option key- Returns:
- the description of the option, or an empty string if the option has no description
-