Class AbstractCommand

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

public abstract class AbstractCommand extends Object implements Command
Base class helping to build shell commands.
Author:
Janne Valkealahti, Piotr Olaszewski, Mahmoud Ben Hassine
  • 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, 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.
      Specified by:
      getHelp in interface Command
      Returns:
      the help text of the command
    • 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)
    • 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