Package org.jline.console.impl
Class AbstractCommandRegistry
- java.lang.Object
-
- org.jline.console.impl.AbstractCommandRegistry
-
- All Implemented Interfaces:
CommandRegistry
- Direct Known Subclasses:
JlineCommandRegistry
public abstract class AbstractCommandRegistry extends java.lang.Object implements CommandRegistry
Abstract base class implementing common methods for command registries.AbstractCommandRegistry provides a base implementation of the CommandRegistry interface, with common methods for registering commands, generating command descriptions, and handling command execution. Concrete implementations can extend this class to create specific command registry types.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
-
-
Constructor Summary
Constructors Constructor Description AbstractCommandRegistry()Creates a new AbstractCommandRegistry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalias(java.lang.String alias, java.lang.String command)java.util.Map<java.lang.String,java.lang.String>commandAliases()Returns a map of alias-to-command names known by this registry.java.util.Set<java.lang.String>commandNames()Returns the command names known by this registry.SystemCompletercompileCompleters()Returns aSystemCompleterthat can provide detailed completion information for all registered commands.CmdDescdoHelpDesc(java.lang.String command, java.util.List<java.lang.String> info, CmdDesc cmdDesc)Creates a command description for a help command.CommandMethodsgetCommandMethods(java.lang.String command)booleanhasCommand(java.lang.String command)Returns whether a command with the specified name is known to this registry.java.lang.Objectinvoke(CommandRegistry.CommandSession session, java.lang.String command, java.lang.Object... args)Execute a command.voidregisterCommands(java.util.Map<java.lang.String,CommandMethods> commandExecute)<T extends java.lang.Enum<T>>
voidregisterCommands(java.util.Map<T,java.lang.String> commandName, java.util.Map<T,CommandMethods> commandExecute)java.lang.ObjectregisteredCommand(java.lang.String command)<V extends java.lang.Enum<V>>
voidrename(V command, java.lang.String newName)voidsaveException(java.lang.Exception exception)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.console.CommandRegistry
commandDescription, commandInfo, name
-
-
-
-
Method Detail
-
doHelpDesc
public CmdDesc doHelpDesc(java.lang.String command, java.util.List<java.lang.String> info, CmdDesc cmdDesc)
Creates a command description for a help command.This method combines the command information with the command description to create a comprehensive help description for the command.
- Parameters:
command- the command nameinfo- the command information as a list of stringscmdDesc- the command description- Returns:
- a command description for the help command
-
registerCommands
public <T extends java.lang.Enum<T>> void registerCommands(java.util.Map<T,java.lang.String> commandName, java.util.Map<T,CommandMethods> commandExecute)
-
registerCommands
public void registerCommands(java.util.Map<java.lang.String,CommandMethods> commandExecute)
-
invoke
public java.lang.Object invoke(CommandRegistry.CommandSession session, java.lang.String command, java.lang.Object... args) throws java.lang.Exception
Description copied from interface:CommandRegistryExecute a command.- Specified by:
invokein interfaceCommandRegistry- 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:
java.lang.Exception- in case of error
-
saveException
public void saveException(java.lang.Exception exception)
-
hasCommand
public boolean hasCommand(java.lang.String command)
Description copied from interface:CommandRegistryReturns whether a command with the specified name is known to this registry.- Specified by:
hasCommandin interfaceCommandRegistry- Parameters:
command- the command name to test- Returns:
- true if the specified command is registered
-
commandNames
public java.util.Set<java.lang.String> commandNames()
Description copied from interface:CommandRegistryReturns the command names known by this registry.- Specified by:
commandNamesin interfaceCommandRegistry- Returns:
- the set of known command names, excluding aliases
-
commandAliases
public java.util.Map<java.lang.String,java.lang.String> commandAliases()
Description copied from interface:CommandRegistryReturns a map of alias-to-command names known by this registry.- Specified by:
commandAliasesin interfaceCommandRegistry- Returns:
- a map with alias keys and command name values
-
rename
public <V extends java.lang.Enum<V>> void rename(V command, java.lang.String newName)
-
alias
public void alias(java.lang.String alias, java.lang.String command)
-
compileCompleters
public SystemCompleter compileCompleters()
Description copied from interface:CommandRegistryReturns aSystemCompleterthat can provide detailed completion information for all registered commands.- Specified by:
compileCompletersin interfaceCommandRegistry- Returns:
- a SystemCompleter that can provide command completion for all registered commands
-
getCommandMethods
public CommandMethods getCommandMethods(java.lang.String command)
-
registeredCommand
public java.lang.Object registeredCommand(java.lang.String command)
-
-