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
-
Constructor Summary
-
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.boolean
hasProperty(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:CommandExecutor
Executes the given command. Sets handled to false if the command does not exist.- Specified by:
execute
in interfaceCommandExecutor
- Parameters:
future
- callback: true if startup should be aborted.commandLine
- the commands/properties to execute.- Returns:
- fluent
-
execute
Description copied from interface:CommandExecutor
Executes the given command synchronously.- Specified by:
execute
in interfaceCommandExecutor
- Parameters:
command
- the command to execute- Returns:
- true if startup is to be aborted.
-
getCommand
Description copied from interface:CommandExecutor
Get the first command passed to the executor.- Specified by:
getCommand
in interfaceCommandExecutor
- Returns:
- the initial command as a string.
-
getParser
-
addProperty
Description copied from interface:CommandExecutor
Adds a new property to the CommandExecutor that is passed to executed commands.- Specified by:
addProperty
in 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:CommandExecutor
Check if a property has been set from the commandline.- Specified by:
hasProperty
in interfaceCommandExecutor
- Parameters:
name
- the name of the property- Returns:
- true if the property exists
-
getProperty
Description copied from interface:CommandExecutor
Get a commandline property passed to the Executor.- Specified by:
getProperty
in interfaceCommandExecutor
- Parameters:
name
- the name of the property to get- Returns:
- the property as a string value
-
getAllProperties
Description copied from interface:CommandExecutor
Get a commandline property passed to the Executor.- Specified by:
getAllProperties
in interfaceCommandExecutor
- Parameters:
name
- the name of the property to get- Returns:
- a list of all the property values.
-
add
Description copied from interface:CommandExecutor
Registers a new command to the CommandExecutor.- Specified by:
add
in 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:CommandExecutor
Adds a new asynchronous command using the default implementation.- Specified by:
add
in 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:CommandExecutor
Adds a new synchronous command using the default implementation.- Specified by:
add
in 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:CommandExecutor
Lists all commands added to the executor.- Specified by:
list
in interfaceCommandExecutor
- Returns:
- a list of commands registered.
-
clear
Description copied from interface:CommandExecutor
Removes all registered commands.- Specified by:
clear
in interfaceCommandExecutor
- Returns:
- fluent.
-