Package org.jline.shell
Interface CommandGroup
- All Known Implementing Classes:
AliasCommands,CommandGroupAdapter,GogoCommandGroup,HelpCommands,HistoryCommands,InteractiveCommandGroup,JobCommands,OptionCommands,PosixCommandGroup,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 TypeMethodDescriptiondefault CommandFinds a command by name or alias.commands()Returns all commands in this group.default booleanhasCommand(String name) Returns whether this group contains a command with the given name or alias.default Stringname()Returns the name of this command group.
-
Method Details
-
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
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
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
-