public abstract class Command extends Object
Constructor and Description |
---|
Command(String[] commandPath)
Default Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addArgument(CommandArgument argument)
Adds a command argument to the argument list
|
void |
addOption(char c,
String description,
String longOpt)
Adds a command option to CLI command
|
void |
addOption(char c,
String description,
String longOpt,
boolean hasArg,
String argName)
Adds a command option to CLI command
|
CommandArgumentResult |
checkArguments(PrintStream out,
List<String> args)
Checks a Command's argument list to determine if the command is valid
|
boolean |
confirm(Location location)
This method confirms the deletion of an object
|
int |
defaultArgumentResultHandler(PrintStream out,
CommandArgumentResult argResult)
A default result handler for handling typical HELP and FAIL cases
|
abstract int |
execute(Location location,
List<String> args)
The abstract call to execute the Command
|
protected List<CommandArgument> |
getCommandArgumentList() |
org.apache.commons.cli.CommandLine |
getCommandLine() |
protected org.apache.commons.cli.Options |
getCommandLineOptions() |
String[] |
getCommandPath() |
jline.console.completer.Completer |
getCompleter(Location currentLocation) |
abstract String |
getUsageDescription() |
String |
getUsageExample() |
String |
getUsageHeader() |
int |
handleBooleanResponse(PrintStream out,
boolean success,
String failureMessage)
Handles the boolean responses for commands from AlpacaLibrary
|
int |
handleResponse(PrintStream out,
co.ecg.alpaca.toolkit.messaging.response.Response r) |
boolean |
isCompleteArgumentList(List<String> providedArgs)
Checks if a set of arguments is complete and prints the remaining items
that need to be entered.
|
void |
printHelp(PrintStream out,
List<String> providedArgs)
Print details on remaining arguments for a command
|
void |
println(PrintStream out,
String s)
This method determines how locations print information to the console
|
void |
printUsage(PrintStream out)
Outputs the usage header, description, and options.
|
public Command(String[] commandPath)
commandPath
- public void addArgument(CommandArgument argument) throws co.ecg.alpaca.toolkit.exception.AlpacaException
argument
- The argumentco.ecg.alpaca.toolkit.exception.AlpacaException
public void addOption(char c, String description, String longOpt)
c
- The short optdescription
- The descriptionlongOpt
- The long optpublic void addOption(char c, String description, String longOpt, boolean hasArg, String argName)
c
- The short optdescription
- The descriptionlongOpt
- The long opthasArg
- Whether the command has an attached argumentpublic CommandArgumentResult checkArguments(PrintStream out, List<String> args) throws co.ecg.alpaca.toolkit.exception.AlpacaException
args
- The argument listco.ecg.alpaca.toolkit.exception.AlpacaException
public int defaultArgumentResultHandler(PrintStream out, CommandArgumentResult argResult) throws co.ecg.alpaca.toolkit.exception.AlpacaException
argResult
- co.ecg.alpaca.toolkit.exception.AlpacaException
public abstract int execute(Location location, List<String> args) throws co.ecg.alpaca.toolkit.exception.AlpacaException
location
- args
- co.ecg.alpaca.toolkit.exception.AlpacaException
protected List<CommandArgument> getCommandArgumentList()
public org.apache.commons.cli.CommandLine getCommandLine()
protected org.apache.commons.cli.Options getCommandLineOptions()
public String[] getCommandPath()
public jline.console.completer.Completer getCompleter(Location currentLocation)
public String getUsageExample()
public abstract String getUsageDescription()
public String getUsageHeader()
public int handleBooleanResponse(PrintStream out, boolean success, String failureMessage) throws co.ecg.alpaca.toolkit.exception.AlpacaException
co.ecg.alpaca.toolkit.exception.AlpacaException
public int handleResponse(PrintStream out, co.ecg.alpaca.toolkit.messaging.response.Response r) throws co.ecg.alpaca.toolkit.exception.AlpacaException
co.ecg.alpaca.toolkit.exception.AlpacaException
public boolean isCompleteArgumentList(List<String> providedArgs)
public void printHelp(PrintStream out, List<String> providedArgs) throws co.ecg.alpaca.toolkit.exception.AlpacaException
co.ecg.alpaca.toolkit.exception.AlpacaException
public void println(PrintStream out, String s)
public void printUsage(PrintStream out) throws co.ecg.alpaca.toolkit.exception.AlpacaException
out
- co.ecg.alpaca.toolkit.exception.AlpacaException
public boolean confirm(Location location)
Copyright © 2016. All rights reserved.