Package com.codingchili.core.context
Class DefaultCommandExecutor
java.lang.Object
com.codingchili.core.context.DefaultCommandExecutor
- All Implemented Interfaces:
CommandExecutor
- Direct Known Subclasses:
LauncherCommandExecutor
Parses and executes commands from the command line.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRegisters a new command to the CommandExecutor.add(BiFunction<io.vertx.core.Promise<CommandResult>,CommandExecutor,Void> executor, String name, String description)Adds a new asynchronous command using the default implementation.add(Function<CommandExecutor,CommandResult> executor, String name, String description)Adds a new synchronous command using the default implementation.addProperty(String key, String value)Adds a new property to the CommandExecutor that is passed to executed commands.clear()Removes all registered commands.execute(io.vertx.core.Promise<CommandResult> future, String... commandLine)Executes the given command.Executes the given command synchronously.getAllProperties(String name)Get a commandline property passed to the Executor.Get the first command passed to the executor.getProperty(String name)Get a commandline property passed to the Executor.booleanhasProperty(String name)Check if a property has been set from the commandline.list()Lists all commands added to the executor.
-
Field Details
-
settings
-
commands
-
logger
-
-
Constructor Details
-
DefaultCommandExecutor
public DefaultCommandExecutor()uses a ConsoleLogger as default. -
DefaultCommandExecutor
- Parameters:
logger- to write output to.
-
-
Method Details
-
execute
Description copied from interface:CommandExecutorExecutes the given command. Sets handled to false if the command does not exist.- Specified by:
executein interfaceCommandExecutor- Parameters:
future- callback: true if startup should be aborted.commandLine- the commands/properties to execute.- Returns:
- fluent
-
execute
Description copied from interface:CommandExecutorExecutes the given command synchronously.- Specified by:
executein interfaceCommandExecutor- Parameters:
command- the command to execute- Returns:
- true if startup is to be aborted.
-
getCommand
Description copied from interface:CommandExecutorGet the first command passed to the executor.- Specified by:
getCommandin interfaceCommandExecutor- Returns:
- the initial command as a string.
-
getParser
-
addProperty
Description copied from interface:CommandExecutorAdds a new property to the CommandExecutor that is passed to executed commands.- Specified by:
addPropertyin interfaceCommandExecutor- Parameters:
key- the key to identify the property byvalue- a value to bind to the property key- Returns:
- fluent
-
hasProperty
Description copied from interface:CommandExecutorCheck if a property has been set from the commandline.- Specified by:
hasPropertyin interfaceCommandExecutor- Parameters:
name- the name of the property- Returns:
- true if the property exists
-
getProperty
Description copied from interface:CommandExecutorGet a commandline property passed to the Executor.- Specified by:
getPropertyin interfaceCommandExecutor- Parameters:
name- the name of the property to get- Returns:
- the property as a string value
-
getAllProperties
Description copied from interface:CommandExecutorGet a commandline property passed to the Executor.- Specified by:
getAllPropertiesin interfaceCommandExecutor- Parameters:
name- the name of the property to get- Returns:
- a list of all the property values.
-
add
Description copied from interface:CommandExecutorRegisters a new command to the CommandExecutor.- Specified by:
addin interfaceCommandExecutor- Parameters:
command- the command to add- Returns:
- fluent
-
add
public CommandExecutor add(BiFunction<io.vertx.core.Promise<CommandResult>,CommandExecutor,Void> executor, String name, String description)Description copied from interface:CommandExecutorAdds a new asynchronous command using the default implementation.- Specified by:
addin interfaceCommandExecutor- Parameters:
executor- the method to execute when the command is executed.name- the name of the command to adddescription- the description of the command- Returns:
- fluent
-
add
public CommandExecutor add(Function<CommandExecutor,CommandResult> executor, String name, String description)Description copied from interface:CommandExecutorAdds a new synchronous command using the default implementation.- Specified by:
addin interfaceCommandExecutor- Parameters:
executor- the method to execute when the command is executedname- the name of the command to adddescription- the description of the command- Returns:
- fluent
-
list
Description copied from interface:CommandExecutorLists all commands added to the executor.- Specified by:
listin interfaceCommandExecutor- Returns:
- a list of commands registered.
-
clear
Description copied from interface:CommandExecutorRemoves all registered commands.- Specified by:
clearin interfaceCommandExecutor- Returns:
- fluent.
-