Interface Command

All Known Implementing Classes:
AbstractCommand, Clear, ConsumerCommandAdapter, FunctionCommandAdapter, Help, History, MethodInvokerCommandAdapter, Script, Version
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Command
Author:
Eric Bottard, Piotr Olaszewski, Mahmoud Ben Hassine
  • Method Details

    • getName

      default String getName()
      Get the name of the command.
      Returns:
      the name of the command
    • getDescription

      default String getDescription()
      Get a short description of the command.
      Returns:
      the description of the command
    • getHelp

      default String getHelp()
      Get the help text of the command. It is reported as the DESCRIPTION section of the detailed help message of the command, which is omitted when the text is empty. Unlike getDescription(), which is a one liner shown in the list of available commands, the help text is meant to be a longer explanation of what the command does.
      Returns:
      the help text of the command, empty when the command does not define one
    • isHidden

      default boolean isHidden()
      Check if the command is hidden.
      Returns:
      true if the command is hidden, false otherwise
    • getGroup

      default String getGroup()
      Get the group of the command.
      Returns:
      the group of the command
    • getAliases

      default List<String> getAliases()
      Get the aliases of the command.
      Returns:
      the aliases of the command
    • getOptions

      default List<CommandOption> getOptions()
      Get the options of the command.
      Returns:
      the options of the command
    • getArguments

      default List<CommandArgument> getArguments()
      Get the arguments of the command.
      Returns:
      the arguments of the command
    • getAvailabilityProvider

      default AvailabilityProvider getAvailabilityProvider()
      Get the availability provider of the command. Defaults to always available.
      Returns:
      the availability provider of the command
    • getCompletionProvider

      default CompletionProvider getCompletionProvider()
      Get the completion provider of the command.
      Returns:
      the completion provider of the command
    • execute

      ExitStatus execute(CommandContext commandContext) throws Exception
      Execute the command within the given context.
      Parameters:
      commandContext - the context of the command
      Returns:
      the exit status of the command
      Throws:
      Exception
    • builder

      static Command.Builder builder()
      Creates and returns a new instance of a Builder for defining and constructing commands.

      The builder allows customization of command properties such as name, description, group, help text, aliases, and execution logic.

      Returns:
      a new Builder instance for configuring and creating commands