public class CmdLine
extends java.lang.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 java.lang.String |
cmd |
private java.util.Map<java.lang.String,java.lang.String> |
options |
Constructor and Description |
---|
CmdLine(java.lang.String[] args)
Create a new object for parsing the command line.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCmd()
Get the command parameter
|
java.lang.String |
getOption(java.lang.String option)
Get the value for the specified option
|
java.lang.String |
getOption(java.lang.String option,
java.lang.String defaultValue)
Get the value for an option.
|
boolean |
hasOption(java.lang.String option)
Check if an option was specified or not.
|
private final java.util.Map<java.lang.String,java.lang.String> options
private final java.lang.String cmd
public CmdLine(java.lang.String[] args)
args
- The command line arguments sent to the main()
methodpublic java.lang.String getCmd()
public java.lang.String getOption(java.lang.String option)
option
- The option to get the value forpublic java.lang.String getOption(java.lang.String option, java.lang.String defaultValue)
option
- The option to get the value fordefaultValue
- A default value if the option wasn't specifiedpublic boolean hasOption(java.lang.String option)
option
- The option to check