public class CmdLine extends Object
Options starts with hyphen (-) and may have a value following it. The last parameter is the command unless it starts with a hyphen.
Examples:
./jobagent.sh start ./jobagent.sh -c agent.properties stop
Modifier and Type | Field and Description |
---|---|
private String |
cmd |
private Map<String,String> |
options |
Constructor and Description |
---|
CmdLine(String[] args)
Create a new object for parsing the command line.
|
Modifier and Type | Method and Description |
---|---|
String |
getCmd()
Get the command parameter
|
String |
getOption(String option)
Get the value for the specified option
|
String |
getOption(String option,
String defaultValue)
Get the value for an option.
|
boolean |
hasOption(String option)
Check if an option was specified or not.
|
public CmdLine(String[] args)
args
- The command line arguments sent to the main()
methodpublic String getCmd()
public String getOption(String option)
option
- The option to get the value forpublic String getOption(String option, String defaultValue)
option
- The option to get the value fordefaultValue
- A default value if the option wasn't specifiedpublic boolean hasOption(String option)
option
- The option to check