public static class CommandLine.RegexTransformer extends Object implements CommandLine.INegatableOptionTransformer
A common way to negate GNU *nix long options is to prefix them with "no-"
, so
for a --force
option the negative version would be --no-force
.
Java has the -XX:[+|-]
JVM options, where
"Boolean options are turned on with -XX:+<option>
and turned off with -XX:-<option>
".
These are the negative forms supported by default by this class.
See the CommandLine.RegexTransformer.Builder
for an example of customizing this to create negative forms for short options.
Modifier and Type | Class and Description |
---|---|
static class |
CommandLine.RegexTransformer.Builder
Builder for creating
RegexTransformer objects. |
Modifier and Type | Method and Description |
---|---|
static CommandLine.RegexTransformer |
createCaseInsensitive()
Returns the
RegexTransformer for case-insensitive negatable options. |
static CommandLine.RegexTransformer |
createDefault()
Returns the
RegexTransformer used by default for negatable options. |
String |
makeNegative(String optionName,
CommandLine.Model.CommandSpec cmd)
Returns the negative form of the specified option name for the parser to recognize when parsing command line arguments.
|
String |
makeSynopsis(String optionName,
CommandLine.Model.CommandSpec cmd)
Returns the documentation string to show in the synopsis and usage help message for the specified option.
|
String |
toString() |
public static CommandLine.RegexTransformer createDefault()
RegexTransformer
used by default for negatable options.
Regex | Negative Replacement | Synopsis Replacement | Comment |
---|---|---|---|
^--no-(\w(-|\w)*)$ | --$1 | --[no-]$1 | Converts --no-force to --force |
^--(\w(-|\w)*)$ | --no-$1 | --[no-]$1 | Converts --force to --no-force |
^(-|--)(\w*:)\+(\w(-|\w)*)$ | $1$2-$3 | $1$2(+|-)$3 | Converts -XX:+Inline to -XX:-Inline |
^(-|--)(\w*:)\-(\w(-|\w)*)$ | $1$2+$3 | $1$2(+|-)$3 | Converts -XX:-Inline to -XX:+Inline |
public static CommandLine.RegexTransformer createCaseInsensitive()
RegexTransformer
for case-insensitive negatable options.
Regex | Negative Replacement | Synopsis Replacement | Comment | |
---|---|---|---|---|
^--((?i)no)-(\w(-|\w)*)$ | --$2 | --[$1-]$2 | Converts --no-force to --force |
and --NO-force to --force |
^--(\w(-|\w)*)$ | --no-$1 | --[no-]$1 | Converts --force to --no-force |
|
^(-|--)(\w*:)\+(\w(-|\w)*)$ | $1$2-$3 | $1$2(+|-)$3 | Converts -XX:+Inline to -XX:-Inline |
|
^(-|--)(\w*:)\-(\w(-|\w)*)$ | $1$2+$3 | $1$2(+|-)$3 | Converts -XX:-Inline to -XX:+Inline |
public String makeNegative(String optionName, CommandLine.Model.CommandSpec cmd)
makeNegative
in interface CommandLine.INegatableOptionTransformer
optionName
- the option name to create a negative form for, for example --force
cmd
- the command that the option is part of--no-force
public String makeSynopsis(String optionName, CommandLine.Model.CommandSpec cmd)
makeSynopsis
in interface CommandLine.INegatableOptionTransformer
optionName
- the option name to create a documentation string for, for example --force
, or -XX:+<option>
cmd
- the command that the option is part of--[no-]force
, or -XX:(+|-)<option>