| java.lang.Object com.mckoi.util.CommandLine
CommandLine | public class CommandLine (Code) | | Used to parse a command-line.
author: Tobias Downer |
Constructor Summary | |
public | CommandLine(String[] args) Constructs the command line parser from the String[] array passed as the
argument to the application. |
Method Summary | |
public String[] | allSwitchesStartingWith(String switch_str) Returns a list of all switches on the command line that start with the
given string. | public boolean | containsSwitch(String switch_str) Returns true if the switch is in the command line.
eg. | public boolean | containsSwitchFrom(String switch_str) Given a comma deliminated list, this scans for one of the switches in the
list. | public boolean | containsSwitchStart(String switch_str) Returns true if the command line contains a switch starting with the
given string. | public String | switchArgument(String switch_str) Returns the contents of a switch variable if the switch is found on the
command line. | public String | switchArgument(String switch_str, String def) Returns the contents of a switch variable if the switch is found on the
command line. | public String[] | switchArguments(String switch_str, int arg_count) Returns the contents of a set of arguments found after a switch on the
command line. |
CommandLine | public CommandLine(String[] args)(Code) | | Constructs the command line parser from the String[] array passed as the
argument to the application.
|
allSwitchesStartingWith | public String[] allSwitchesStartingWith(String switch_str)(Code) | | Returns a list of all switches on the command line that start with the
given string. eg. command_line.allSwitchesStartingWith("-D"); will
return matches for switches "-Dname=toby", "-Dog", "-Dvalue=over", etc.
|
containsSwitch | public boolean containsSwitch(String switch_str)(Code) | | Returns true if the switch is in the command line.
eg. command_line.containsSwitch("--help");
|
containsSwitchFrom | public boolean containsSwitchFrom(String switch_str)(Code) | | Given a comma deliminated list, this scans for one of the switches in the
list. eg. command_line.containsSwitchFrom("--help,-help,-h");
|
containsSwitchStart | public boolean containsSwitchStart(String switch_str)(Code) | | Returns true if the command line contains a switch starting with the
given string. eg. command_line.containsSwitchStart("-he"); will match
"-hello", "-help", "-her", etc
|
switchArgument | public String switchArgument(String switch_str)(Code) | | Returns the contents of a switch variable if the switch is found on the
command line. A switch variable is of the form '-[switch] [variable]'.
eg. 'command.exe -url "http://www.mckoi.com/database/"'.
Returns 'null' if the argument was not found.
|
switchArgument | public String switchArgument(String switch_str, String def)(Code) | | Returns the contents of a switch variable if the switch is found on the
command line. A switch variable is of the form '-[switch] [variable]'.
eg. 'command.exe -url "http://www.mckoi.com/database/"'.
Returns def if the argument was not found.
|
switchArguments | public String[] switchArguments(String switch_str, int arg_count)(Code) | | Returns the contents of a set of arguments found after a switch on the
command line. For example, switchArguments("-create", 3) would try and
find the '-create' switch and return the first 3 arguments after it if
it can.
Returns null if no match is found.
|
|
|