Class CmdDesc

java.lang.Object
org.jline.console.CmdDesc

public class CmdDesc extends Object
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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new command description that is not a command.
    CmdDesc(boolean valid)
    Creates a new command description with the specified validity.
    CmdDesc(List<ArgDesc> argsDesc)
    Creates a new command description with the specified argument descriptions.
    CmdDesc(List<ArgDesc> argsDesc, Map<String,List<org.jline.utils.AttributedString>> optsDesc)
    Creates a new command description with the specified argument and option descriptions.
    CmdDesc(List<org.jline.utils.AttributedString> mainDesc, List<ArgDesc> argsDesc, Map<String,List<org.jline.utils.AttributedString>> optsDesc)
    Creates a new command description with the specified main description, argument descriptions, and option descriptions.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the descriptions of the command's arguments.
    int
    Returns the index of the error in the command.
    Returns the pattern used to identify errors in the command.
    List<org.jline.utils.AttributedString>
    Returns the main description of the command.
    TreeMap<String,List<org.jline.utils.AttributedString>>
    Returns the descriptions of the command's options.
    boolean
    Returns whether this is a command (as opposed to a method or syntax).
    boolean
    Returns whether the command should be highlighted.
    boolean
    Returns whether this is a subcommand.
    boolean
    Returns whether the command is valid.
    mainDesc(List<org.jline.utils.AttributedString> mainDesc)
    Sets the main description of the command and returns this command description.
    org.jline.utils.AttributedString
    Returns the description of the specified option.
    boolean
    Returns whether the specified option takes a value.
    void
    setErrorIndex(int errorIndex)
    Sets the index of the error in the command.
    void
    setErrorPattern(Pattern errorPattern)
    Sets the pattern used to identify errors in the command.
    void
    setHighlighted(boolean highlighted)
    Sets whether the command should be highlighted.
    void
    setMainDesc(List<org.jline.utils.AttributedString> mainDesc)
    Sets the main description of the command.
    void
    setSubcommand(boolean subcommand)
    Sets whether this is a subcommand.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public CmdDesc(List<ArgDesc> argsDesc)
      Creates a new command description with the specified argument descriptions.
      Parameters:
      argsDesc - the descriptions of the command's arguments
    • CmdDesc

      public CmdDesc(List<ArgDesc> argsDesc, Map<String,List<org.jline.utils.AttributedString>> optsDesc)
      Creates a new command description with the specified argument and option descriptions.
      Parameters:
      argsDesc - the descriptions of the command's arguments
      optsDesc - the descriptions of the command's options
    • CmdDesc

      public CmdDesc(List<org.jline.utils.AttributedString> mainDesc, List<ArgDesc> argsDesc, Map<String,List<org.jline.utils.AttributedString>> optsDesc)
      Creates a new command description with the specified main description, argument descriptions, and option descriptions.
      Parameters:
      mainDesc - the main description of the command
      argsDesc - the descriptions of the command's arguments
      optsDesc - 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

      public CmdDesc mainDesc(List<org.jline.utils.AttributedString> 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

      public void setMainDesc(List<org.jline.utils.AttributedString> mainDesc)
      Sets the main description of the command.
      Parameters:
      mainDesc - the main description of the command
    • getMainDesc

      public List<org.jline.utils.AttributedString> getMainDesc()
      Returns the main description of the command.
      Returns:
      the main description of the command
    • getOptsDesc

      public TreeMap<String,List<org.jline.utils.AttributedString>> getOptsDesc()
      Returns the descriptions of the command's options.
      Returns:
      the descriptions of the command's options
    • setErrorPattern

      public void setErrorPattern(Pattern errorPattern)
      Sets the pattern used to identify errors in the command.
      Parameters:
      errorPattern - the pattern used to identify errors
    • getErrorPattern

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

      public List<ArgDesc> getArgsDesc()
      Returns the descriptions of the command's arguments.
      Returns:
      the descriptions of the command's arguments
    • optionWithValue

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

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