Interface CommandGroup

All Known Implementing Classes:
AliasCommands, ExitCommands, HelpCommands, HistoryCommands, JobCommands, OptionCommands, ScriptCommands, SimpleCommandGroup, VariableCommands

public interface CommandGroup
A named group of Commands for organization and discovery.

CommandGroup provides a pure discovery and organizational role. Execution and completion concerns belong to CommandDispatcher.

Example:

 CommandGroup group = new SimpleCommandGroup("myapp", echoCmd, greetCmd);
 dispatcher.addGroup(group);
 
Since:
4.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Command
    Finds a command by name or alias.
    Returns all commands in this group.
    default boolean
    Returns whether this group contains a command with the given name or alias.
    default String
    Returns the name of this command group.
  • Method Details

    • name

      default String name()
      Returns the name of this command group.

      The default implementation returns the simple class name.

      Returns:
      the group name
    • commands

      Collection<Command> commands()
      Returns all commands in this group.
      Returns:
      the collection of commands, never null
    • command

      default Command command(String name)
      Finds a command by name or alias.

      The default implementation scans commands() for a match.

      Parameters:
      name - the command name or alias
      Returns:
      the command, or null if not found
    • hasCommand

      default boolean hasCommand(String name)
      Returns whether this group contains a command with the given name or alias.
      Parameters:
      name - the command name or alias
      Returns:
      true if a matching command exists