public class Command
extends java.lang.Object
A command's logic and possible parameters are defined by writing a logic class extending CommandLogic. For more information about CommandLogic, consult the CommandLogic documentation
Constructor and Description |
---|
Command(java.lang.String name,
java.lang.String description,
CommandLogic logic)
Sets the name of the command function (for example, "find" or "grep") and
inherits parameters from command logic, if any.
|
Modifier and Type | Method and Description |
---|---|
void |
addReference(java.lang.String reference)
Adds a possible reference to the command
|
void |
appendUsage(java.lang.String append)
Adds additional information to the command's usage info
|
java.lang.String |
getDefaultReference() |
java.lang.String |
getDescription() |
java.lang.String |
getName() |
java.util.ArrayList<java.lang.String> |
getReferences() |
java.lang.String |
getUsage()
Gives the correct usage in a standard, user-friendly format
|
void |
resetUsage(java.lang.String reset)
Replaces the command's usage info with a given String
|
void |
run(java.lang.String[] args)
Runs the command logic with the given arguments
|
public Command(java.lang.String name, java.lang.String description, CommandLogic logic)
name
- Command namedescription
- Command descriptionlogic
- Command logicpublic java.lang.String getName()
public java.lang.String getDescription()
public java.lang.String getDefaultReference()
public java.util.ArrayList<java.lang.String> getReferences()
public void addReference(java.lang.String reference)
reference
- public java.lang.String getUsage()
public void appendUsage(java.lang.String append)
append
- Information to append to usagepublic void resetUsage(java.lang.String reset)
reset
- New usage info to displaypublic void run(java.lang.String[] args)
args
- Command-line arguments