Package com.codingchili.core.context
Interface CommandExecutor
- All Known Implementing Classes:
DefaultCommandExecutor,LauncherCommandExecutor
public interface CommandExecutor
Interface that can be implemented to handle commandline arguments.
Used by #
LaunchContext.-
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.
-
Method Details
-
execute
Executes the given command. Sets handled to false if the command does not exist.- Parameters:
future- callback: true if startup should be aborted.commandLine- the commands/properties to execute.- Returns:
- fluent
-
execute
Executes the given command synchronously.- Parameters:
command- the command to execute- Returns:
- true if startup is to be aborted.
-
getCommand
Get the first command passed to the executor.- Returns:
- the initial command as a string.
-
addProperty
Adds a new property to the CommandExecutor that is passed to executed commands.- Parameters:
key- the key to identify the property byvalue- a value to bind to the property key- Returns:
- fluent
-
hasProperty
Check if a property has been set from the commandline.- Parameters:
name- the name of the property- Returns:
- true if the property exists
-
getProperty
Get a commandline property passed to the Executor.- Parameters:
name- the name of the property to get- Returns:
- the property as a string value
-
getAllProperties
Get a commandline property passed to the Executor.- Parameters:
name- the name of the property to get- Returns:
- a list of all the property values.
-
add
Registers a new command to the CommandExecutor.- Parameters:
command- the command to add- Returns:
- fluent
-
add
CommandExecutor add(BiFunction<io.vertx.core.Promise<CommandResult>,CommandExecutor,Void> executor, String name, String description)Adds a new asynchronous command using the default implementation.- 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
CommandExecutor add(Function<CommandExecutor,CommandResult> executor, String name, String description)Adds a new synchronous command using the default implementation.- 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
Collection<Command> list()Lists all commands added to the executor.- Returns:
- a list of commands registered.
-
clear
CommandExecutor clear()Removes all registered commands.- Returns:
- fluent.
-