|
Griffon 1.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.griffon.cli.parsing.CommandLineParser
public class CommandLineParser
Command line parser that parses arguments to the command line. Written as a replacement for Commons CLI because it doesn't support unknown arguments and requires all arguments to be declared up front.
It also doesn't support command options with hyphens. This class gets around those problems.Field Summary | |
---|---|
static Map |
DEFAULT_ENVS
|
private static String |
DEFAULT_PADDING
|
static Map |
ENV_ARGS
|
private Map |
declaredOptions
|
private int |
longestOptionNameLength
|
Constructor Summary | |
CommandLineParser()
|
Method Summary | |
---|---|
void
|
addOption(String name, String description)
Adds a declared option |
protected DefaultCommandLine
|
createCommandLine()
|
static String
|
getDefaultEnvironmentForScript(String scriptName)
|
static String
|
getExtendedEnvironmnentName(String env)
|
String
|
getHelpMessage()
|
CommandLine
|
parse(String... args)
Parses the given list of command line arguments. |
private void
|
parseInternal(DefaultCommandLine cl, String[] args, boolean firstArgumentIsCommand)
|
CommandLine
|
parseString(String string)
Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args) |
CommandLine
|
parseString(String commandName, String args)
Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args) |
protected void
|
processOption(DefaultCommandLine cl, String arg)
|
protected void
|
processSystemArg(DefaultCommandLine cl, String arg)
|
private void
|
validateOptionName(String name)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
static Map DEFAULT_ENVS
private static final String DEFAULT_PADDING
static Map ENV_ARGS
private Map declaredOptions
private int longestOptionNameLength
Constructor Detail |
---|
CommandLineParser()
Method Detail |
---|
public void addOption(String name, String description)
name
- The name of the optiondescription
- The description
protected DefaultCommandLine createCommandLine()
public static String getDefaultEnvironmentForScript(String scriptName)
public static String getExtendedEnvironmnentName(String env)
public String getHelpMessage()
public CommandLine parse(String... args)
args
- The arguments
private void parseInternal(DefaultCommandLine cl, String[] args, boolean firstArgumentIsCommand)
public CommandLine parseString(String string)
string
- The string
public CommandLine parseString(String commandName, String args)
commandName
- The command nameargs
- The string
protected void processOption(DefaultCommandLine cl, String arg)
protected void processSystemArg(DefaultCommandLine cl, String arg)
private void validateOptionName(String name)
Groovy Documentation