Package org.apache.commons.cli
Class GroovyInternalPosixParser
java.lang.Object
org.apache.commons.cli.Parser
org.apache.commons.cli.GroovyInternalPosixParser
- All Implemented Interfaces:
org.apache.commons.cli.CommandLineParser
public class GroovyInternalPosixParser
extends org.apache.commons.cli.Parser
DO NOT USE. Hacked version until Commons CLI 1.3 is released.
NOTE: this is a mirror copy of org.codehaus.groovy.cli.GroovyPosixParser
DON'T MAKE CHANGES without keeping the other file in sync!
The class GroovyPosixParser provides an implementation of the
flatten method.- Author:
- John Keyes (john at integralsource.com), Paul King (Groovy hacks/fixes)
-
Field Summary
Fields inherited from class org.apache.commons.cli.Parser
cmd -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidburstToken(String token, boolean stopAtNonOption) Breakstokeninto its constituent parts using the following algorithm.protected String[]An implementation ofParser's abstractflattenmethod.Methods inherited from class org.apache.commons.cli.Parser
checkRequiredOptions, getOptions, getRequiredOptions, parse, parse, parse, parse, processArgs, processOption, processProperties, setOptions
-
Constructor Details
-
GroovyInternalPosixParser
public GroovyInternalPosixParser()
-
-
Method Details
-
flatten
protected String[] flatten(org.apache.commons.cli.Options options, String[] arguments, boolean stopAtNonOption) An implementation ofParser's abstractflattenmethod.The following are the rules used by this flatten method.
- if
stopAtNonOptionis true then do not burst anymore ofargumentsentries, just add each successive entry without further processing. Otherwise, ignorestopAtNonOption. - if the current
argumentsentry is "--" just add the entry to the list of processed tokens - if the current
argumentsentry is "-" just add the entry to the list of processed tokens - if the current
argumentsentry is two characters in length and the first character is "-" then check if this is a validOptionid. If it is a valid id, then add the entry to the list of processed tokens and set the currentOptionmember. If it is not a valid id andstopAtNonOptionis true, then the remaining entries are copied to the list of processed tokens. Otherwise, the current entry is ignored. - if the current
argumentsentry is more than two characters in length and the first character is "-" then we need to burst the entry to determine its constituents. For more information on the bursting algorithm seeburstToken. - if the current
argumentsentry is not handled by any of the previous rules, then the entry is added to the list of processed tokens.
- Specified by:
flattenin classorg.apache.commons.cli.Parser- Parameters:
options- The command lineOptionsarguments- The command line arguments to be parsedstopAtNonOption- Specifies whether to stop flattening when an non option is found.- Returns:
- The flattened
argumentsString array.
- if
-
burstToken
Breakstokeninto its constituent parts using the following algorithm.- ignore the first character ("-")
- foreach remaining character check if an
Optionexists with that id. - if an
Optiondoes exist then add that character prepended with "-" to the list of processed tokens. - if the
Optioncan have an argument value and there are remaining characters in the token then add the remaining characters as a token to the list of processed tokens. - if an
Optiondoes NOT exist ANDstopAtNonOptionIS set then add the special token "--" followed by the remaining characters and also the remaining tokens directly to the processed tokens list. - if an
Optiondoes NOT exist ANDstopAtNonOptionIS NOT set then add that character prepended with "-".
- Parameters:
token- The current token to be burststopAtNonOption- Specifies whether to stop processing at the first non-Option encountered.
-