Package org.jline.console
Interface CommandRegistry
- All Known Subinterfaces:
ConsoleEngine
,SystemRegistry
- All Known Implementing Classes:
AbstractCommandRegistry
,Builtins
,ConsoleEngineImpl
,DefaultPrinter
,JlineCommandRegistry
,SystemRegistryImpl
public interface CommandRegistry
Store command information, compile tab completers and execute registered commands.
- Author:
- Matti Rinta-Nikkola
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SystemCompleter
aggregateCompleters
(CommandRegistry... commandRegistries) Aggregate SystemCompleters of commandRegisteriesReturns a map of alias-to-command names known by this registry.commandDescription
(List<String> args) Returns a command description for use in the JLine Widgets framework.commandInfo
(String command) Returns a short info about command known by this registry.Returns the command names known by this registry.Returns aSystemCompleter
that can provide detailed completion information for all registered commands.static SystemCompleter
compileCompleters
(CommandRegistry... commandRegistries) Aggregate and compile SystemCompleters of commandRegisteriesboolean
hasCommand
(String command) Returns whether a command with the specified name is known to this registry.default Object
invoke
(CommandRegistry.CommandSession session, String command, Object... args) Execute a command.default String
name()
Returns the name of this registry.
-
Method Details
-
aggregateCompleters
Aggregate SystemCompleters of commandRegisteries- Parameters:
commandRegistries
- command registeries which completers is to be aggregated- Returns:
- uncompiled SystemCompleter
-
compileCompleters
Aggregate and compile SystemCompleters of commandRegisteries- Parameters:
commandRegistries
- command registeries which completers is to be aggregated and compile- Returns:
- compiled SystemCompleter
-
name
Returns the name of this registry.- Returns:
- the name of the registry
-
commandNames
Returns the command names known by this registry.- Returns:
- the set of known command names, excluding aliases
-
commandAliases
Returns a map of alias-to-command names known by this registry.- Returns:
- a map with alias keys and command name values
-
commandInfo
Returns a short info about command known by this registry.- Parameters:
command
- the command name- Returns:
- a short info about command
-
hasCommand
Returns whether a command with the specified name is known to this registry.- Parameters:
command
- the command name to test- Returns:
- true if the specified command is registered
-
compileCompleters
SystemCompleter compileCompleters()Returns aSystemCompleter
that can provide detailed completion information for all registered commands.- Returns:
- a SystemCompleter that can provide command completion for all registered commands
-
commandDescription
Returns a command description for use in the JLine Widgets framework. Default method must be overridden to return sub command descriptions.- Parameters:
args
- command (args[0]) and its arguments- Returns:
- command description for JLine TailTipWidgets to be displayed in the terminal status bar.
-
invoke
default Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception Execute a command.- Parameters:
session
- the data of the current command sessioncommand
- the name of the commandargs
- arguments of the command- Returns:
- result of the command execution
- Throws:
Exception
- in case of error
-