Class AbstractParentCommand

java.lang.Object
dev.metaschema.cli.processor.command.AbstractParentCommand
All Implemented Interfaces:
ICommand
Direct Known Subclasses:
MetapathCommand

public abstract class AbstractParentCommand extends Object implements ICommand
A base class for a command that supports hierarchical command structure with child commands. This class provides the foundation for implementing complex CLI commands that can have multiple levels of sub-commands.

This class is thread-safe and supports concurrent access to command handlers.

  • Constructor Details

    • AbstractParentCommand

      protected AbstractParentCommand()
      Construct a new parent command.
  • Method Details

    • addCommandHandler

      protected final void addCommandHandler(ICommand handler)
      Add a child command.
      Parameters:
      handler - the command handler for the child command
    • getSubCommandByName

      public ICommand getSubCommandByName(String name)
      Description copied from interface: ICommand
      Get a sub-command by it's command name.
      Specified by:
      getSubCommandByName in interface ICommand
      Parameters:
      name - the requested sub-command name
      Returns:
      the command or null if no sub-command exists with that name
    • getSubCommands

      public Collection<ICommand> getSubCommands()
      Description copied from interface: ICommand
      Get any sub-commands associated with this command.
      Specified by:
      getSubCommands in interface ICommand
      Returns:
      the sub-commands
    • isSubCommandRequired

      public boolean isSubCommandRequired()
      Description copied from interface: ICommand
      Determine if this command requires the use of a sub-command.
      Specified by:
      isSubCommandRequired in interface ICommand
      Returns:
      true if a sub-command is required or false otherwise
    • newExecutor

      public ICommandExecutor newExecutor(CallingContext callingContext, org.apache.commons.cli.CommandLine cmdLine)
      Description copied from interface: ICommand
      Create a new executor for this command.
      Specified by:
      newExecutor in interface ICommand
      Parameters:
      callingContext - the context of the command execution
      cmdLine - the parsed command line details
      Returns:
      the executor