Class CommandDescription

java.lang.Object
org.jline.shell.CommandDescription

public class CommandDescription extends Object
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:
  • Method Details

    • mainDescription

      public List<org.jline.utils.AttributedString> mainDescription()
      Returns the main description lines.
      Returns:
      the main description, never null
    • arguments

      public List<ArgumentDescription> arguments()
      Returns the argument descriptions.
      Returns:
      the arguments, never null
    • options

      public Map<String,List<org.jline.utils.AttributedString>> 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

      public boolean optionWithValue(String option)
      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

      public org.jline.utils.AttributedString optionDescription(String key)
      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

      public Pattern 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

      public static CommandDescription.Builder builder()
      Creates a new builder.
      Returns:
      a new builder