java.lang.Object
org.jline.shell.CommandDescription
Describes a command for help display and widget integration.
Uses a builder pattern and record-style accessors. Instances are immutable once built.
Example:
CommandDescription desc = CommandDescription.builder()
.mainDescription(List.of(new AttributedString("list files")))
.argument(new ArgumentDescription("path"))
.option("-l --long", List.of(new AttributedString("long format")))
.build();
- Since:
- 4.0
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns the argument descriptions.static CommandDescription.Builderbuilder()Creates a new builder.intReturns the error index, or -1 if none.Returns the pattern for identifying errors, or null.booleanReturns whether this description represents a command (as opposed to a method or syntax).booleanReturns whether the command should be highlighted.booleanReturns whether this description represents a subcommand.booleanisValid()Returns whether this description represents a valid command.List<org.jline.utils.AttributedString> Returns the main description lines.org.jline.utils.AttributedStringoptionDescription(String key) Returns the first line of description for the specified option key.options()Returns the option descriptions, keyed by option syntax.booleanoptionWithValue(String option) Returns whether the specified option takes a value.
-
Method Details
-
mainDescription
Returns the main description lines.- Returns:
- the main description, never null
-
arguments
Returns the argument descriptions.- Returns:
- the arguments, never null
-
options
Returns the option descriptions, keyed by option syntax.- Returns:
- the options map, never null
-
isValid
public boolean isValid()Returns whether this description represents a valid command.- Returns:
- true if valid
-
isCommand
public boolean isCommand()Returns whether this description represents a command (as opposed to a method or syntax).- Returns:
- true if this is a command description
-
isSubcommand
public boolean isSubcommand()Returns whether this description represents a subcommand.- Returns:
- true if this is a subcommand
-
optionWithValue
Returns whether the specified option takes a value.An option is considered to take a value if its key in the options map contains an
=character (e.g.,"-o --output=FILE").- Parameters:
option- the option to check (e.g.,"-o")- Returns:
- true if the option takes a value
-
optionDescription
Returns the first line of description for the specified option key.- Parameters:
key- the option key as it appears in the options map- Returns:
- the first description line, or an empty string if none
-
isHighlighted
public boolean isHighlighted()Returns whether the command should be highlighted.- Returns:
- true if highlighted
-
errorPattern
Returns the pattern for identifying errors, or null.- Returns:
- the error pattern
-
errorIndex
public int errorIndex()Returns the error index, or -1 if none.- Returns:
- the error index
-
builder
Creates a new builder.- Returns:
- a new builder
-