Class AbstractCommand

java.lang.Object
org.springframework.shell.core.command.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
Clear, ConsumerCommandAdapter, FunctionCommandAdapter, Help, History, MethodInvokerCommandAdapter, Script, Version

public abstract class AbstractCommand extends Object implements Command
Base class helping to build shell commands.
Author:
Janne Valkealahti, Piotr Olaszewski, Mahmoud Ben Hassine, David Pilar
  • Constructor Details

    • AbstractCommand

      public AbstractCommand(String name, String description)
    • AbstractCommand

      public AbstractCommand(String name, String description, String group)
    • AbstractCommand

      public AbstractCommand(String name, String description, String group, String help)
    • AbstractCommand

      public AbstractCommand(String name, String description, String group, String help, boolean hidden)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Command
      Get the name of the command.
      Specified by:
      getName in interface Command
      Returns:
      the name of the command
    • getGroup

      public String getGroup()
      Description copied from interface: Command
      Get the group of the command.
      Specified by:
      getGroup in interface Command
      Returns:
      the group of the command
    • getDescription

      public String getDescription()
      Description copied from interface: Command
      Get a short description of the command.
      Specified by:
      getDescription in interface Command
      Returns:
      the description of the command
    • getHelp

      public String getHelp()
      Description copied from interface: Command
      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 Command.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.
      Specified by:
      getHelp in interface Command
      Returns:
      the help text of the command, empty when the command does not define one
    • isHidden

      public boolean isHidden()
      Description copied from interface: Command
      Check if the command is hidden.
      Specified by:
      isHidden in interface Command
      Returns:
      true if the command is hidden, false otherwise
    • getAliases

      public List<String> getAliases()
      Description copied from interface: Command
      Get the aliases of the command.
      Specified by:
      getAliases in interface Command
      Returns:
      the aliases of the command
    • setAliases

      public void setAliases(List<String> aliases)
    • getOptions

      public List<CommandOption> getOptions()
      Description copied from interface: Command
      Get the options of the command.
      Specified by:
      getOptions in interface Command
      Returns:
      the options of the command
    • setOptions

      public void setOptions(List<CommandOption> options)
    • getArguments

      public List<CommandArgument> getArguments()
      Description copied from interface: Command
      Get the arguments of the command.
      Specified by:
      getArguments in interface Command
      Returns:
      the arguments of the command
    • setArguments

      public void setArguments(List<CommandArgument> arguments)
    • getAvailabilityProvider

      public AvailabilityProvider getAvailabilityProvider()
      Description copied from interface: Command
      Get the availability provider of the command. Defaults to always available.
      Specified by:
      getAvailabilityProvider in interface Command
      Returns:
      the availability provider of the command
    • setAvailabilityProvider

      public void setAvailabilityProvider(AvailabilityProvider availabilityProvider)
    • getExitStatusExceptionMapper

      public @Nullable ExitStatusExceptionMapper getExitStatusExceptionMapper()
    • setExitStatusExceptionMapper

      public void setExitStatusExceptionMapper(ExitStatusExceptionMapper exitStatusExceptionMapper)
    • getCompletionProvider

      public CompletionProvider getCompletionProvider()
      Description copied from interface: Command
      Get the completion provider of the command.
      Specified by:
      getCompletionProvider in interface Command
      Returns:
      the completion provider of the command
    • setCompletionProvider

      public void setCompletionProvider(CompletionProvider completionProvider)
    • execute

      public ExitStatus execute(CommandContext commandContext) throws Exception
      Description copied from interface: Command
      Execute the command within the given context.
      Specified by:
      execute in interface Command
      Parameters:
      commandContext - the context of the command
      Returns:
      the exit status of the command
      Throws:
      Exception
    • println

      protected void println(String message, CommandContext commandContext)
    • isHelp

      protected boolean isHelp(CommandOption option)
    • doExecute

      public abstract ExitStatus doExecute(CommandContext commandContext) throws Exception
      Throws:
      Exception
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object