public class CommandRunner extends Object implements Iterable<Command>
Commands.addCommand(Command), 
runAndHandleErrors(String[])| Constructor and Description | 
|---|
| CommandRunner(String name)Create a new  CommandRunnerinstance. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addCommand(Command command)Add the specified command. | 
| void | addCommands(Iterable<Command> commands)Add the specified commands. | 
| protected void | afterRun(Command command)Subclass hook called after a command has run. | 
| protected void | beforeRun(Command command)Subclass hook called before a command is run. | 
| protected boolean | errorMessage(String message) | 
| Command | findCommand(String name)Find a command by name. | 
| protected List<Command> | getCommands() | 
| String | getName()Return the name of the runner or an empty string. | 
| boolean | isOptionCommand(Command command)Returns if the specified command is an option command. | 
| Iterator<Command> | iterator() | 
| protected void | printStackTrace(Exception ex) | 
| protected ExitStatus | run(String... args)Parse the arguments and run a suitable command. | 
| int | runAndHandleErrors(String... args)Run the appropriate and handle and errors. | 
| void | setHiddenCommands(Class<?>... commandClasses)Set the command classes which should be hidden (i.e. | 
| void | setOptionCommands(Class<?>... commandClasses)Set the command classes which should be considered option commands. | 
| protected void | showUsage() | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic CommandRunner(String name)
CommandRunner instance.name - the name of the runner or nullpublic String getName()
public void addCommands(Iterable<Command> commands)
commands - the commands to addpublic void addCommand(Command command)
command - the command to add.public void setOptionCommands(Class<?>... commandClasses)
commandClasses - the classes of option commands.isOptionCommand(Command)public void setHiddenCommands(Class<?>... commandClasses)
commandClasses - the classes of hidden commandspublic boolean isOptionCommand(Command command)
command - the command to testtrue if the command is an option commandsetOptionCommands(Class...)public Command findCommand(String name)
name - the name of the commandnull if not foundpublic int runAndHandleErrors(String... args)
args - the input argumentsprotected ExitStatus run(String... args) throws Exception
args - the argumentsException - if the command failsprotected void beforeRun(Command command)
command - the command about to runprotected void afterRun(Command command)
command - the command that has runprotected boolean errorMessage(String message)
protected void showUsage()
protected void printStackTrace(Exception ex)
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.