Package picocli
Class CommandLine.RegexTransformer
- java.lang.Object
-
- picocli.CommandLine.RegexTransformer
-
- All Implemented Interfaces:
CommandLine.INegatableOptionTransformer
- Enclosing class:
- CommandLine
public static class CommandLine.RegexTransformer extends java.lang.Object implements CommandLine.INegatableOptionTransformer
A regular expression-based option name transformation for negatable options.A common way to negate GNU *nix long options is to prefix them with
"no-", so for a--forceoption 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.Builderfor an example of customizing this to create negative forms for short options.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommandLine.RegexTransformer.BuilderBuilder for creatingRegexTransformerobjects.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandLine.RegexTransformercreateCaseInsensitive()Returns theRegexTransformerfor case-insensitive negatable options.static CommandLine.RegexTransformercreateDefault()Returns theRegexTransformerused by default for negatable options.java.lang.StringmakeNegative(java.lang.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.java.lang.StringmakeSynopsis(java.lang.String optionName, CommandLine.Model.CommandSpec cmd)Returns the documentation string to show in the synopsis and usage help message for the specified option.java.lang.StringtoString()
-
-
-
Method Detail
-
createDefault
public static CommandLine.RegexTransformer createDefault()
Returns theRegexTransformerused by default for negatable options.The regular expressions used by default for negatable options Regex Negative Replacement Synopsis Replacement Comment ^--no-(\w(-|\w)*)$ --$1 --[no-]$1 Converts --no-forceto--force^--(\w(-|\w)*)$ --no-$1 --[no-]$1 Converts --forceto--no-force^(-|--)(\w*:)\+(\w(-|\w)*)$ $1$2-$3 $1$2(+|-)$3 Converts -XX:+Inlineto-XX:-Inline^(-|--)(\w*:)\-(\w(-|\w)*)$ $1$2+$3 $1$2(+|-)$3 Converts -XX:-Inlineto-XX:+Inline
-
createCaseInsensitive
public static CommandLine.RegexTransformer createCaseInsensitive()
Returns theRegexTransformerfor case-insensitive negatable options.The regular expressions for case-insensitive negatable options Regex Negative Replacement Synopsis Replacement Comment ^--((?i)no)-(\w(-|\w)*)$ --$2 --[$1-]$2 Converts --no-forceto--forceand --NO-forceto--force^--(\w(-|\w)*)$ --no-$1 --[no-]$1 Converts --forceto--no-force^(-|--)(\w*:)\+(\w(-|\w)*)$ $1$2-$3 $1$2(+|-)$3 Converts -XX:+Inlineto-XX:-Inline^(-|--)(\w*:)\-(\w(-|\w)*)$ $1$2+$3 $1$2(+|-)$3 Converts -XX:-Inlineto-XX:+Inline
-
makeNegative
public java.lang.String makeNegative(java.lang.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.- Specified by:
makeNegativein interfaceCommandLine.INegatableOptionTransformer- Parameters:
optionName- the option name to create a negative form for, for example--forcecmd- the command that the option is part of- Returns:
- the negative form of the specified option name, for example
--no-force
-
makeSynopsis
public java.lang.String makeSynopsis(java.lang.String optionName, CommandLine.Model.CommandSpec cmd)Returns the documentation string to show in the synopsis and usage help message for the specified option. The returned value should be concise and clearly suggest that both the positive and the negative form are valid option names- Specified by:
makeSynopsisin interfaceCommandLine.INegatableOptionTransformer- Parameters:
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- Returns:
- the documentation string for the negatable option, for example
--[no-]force, or-XX:(+|-)<option>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-