iterator() { throw new UnsupportedOperationException(); }
+ }
+ /** Specifies the scope of the element.
+ * @since 4.3 */
+ public enum ScopeType {
+ /** The element only exists in the current command. */
+ LOCAL,
+ /** The element exists in the command where the element is defined and all descendents (subcommands, sub-subcommands, etc.). */
+ INHERIT,
+ }
+ /**
+ *
+ * Annotate fields in your class with {@code @Option} and picocli will initialize these fields when matching
+ * arguments are specified on the command line. In the case of command methods (annotated with {@code @Command}),
+ * command options can be defined by annotating method parameters with {@code @Option}.
+ *
+ * Command class example:
+ *
+ *
+ * import static io.mosn.coder.cli.CommandLine.*;
+ *
+ * public class MyClass {
+ * @Parameters(description = "Any number of input files")
+ * private List<File> files = new ArrayList<File>();
+ *
+ * @Option(names = { "-o", "--out" }, description = "Output file (default: print to console)")
+ * private File outputFile;
+ *
+ * @Option(names = { "-v", "--verbose"}, description = "Verbose mode. Helpful for troubleshooting. Multiple -v options increase the verbosity.")
+ * private boolean[] verbose;
+ *
+ * @Option(names = { "-h", "--help", "-?", "-help"}, usageHelp = true, description = "Display this help and exit")
+ * private boolean help;
+ * }
+ *
+ *
+ * A field cannot be annotated with both {@code @Parameters} and {@code @Option} or a
+ * {@code ParameterException} is thrown.
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+ public @interface Option {
+ /** Special value that can be used in some annotation attributes to designate {@code null}.
+ * @see Option#defaultValue()
+ * @see Option#fallbackValue()
+ * @see Option#mapFallbackValue()
+ * @since 4.6 */
+ public static final String NULL_VALUE = ArgSpec.NULL_VALUE;
+ /**
+ * One or more option names. At least one option name is required.
+ *
+ * Different environments have different conventions for naming options, but usually options have a prefix
+ * that sets them apart from parameters.
+ * Picocli supports all of the below styles. The default separator is {@code '='}, but this can be configured.
+ *
+ * *nix
+ *
+ * In Unix and Linux, options have a short (single-character) name, a long name or both.
+ * Short options
+ * (POSIX
+ * style are single-character and are preceded by the {@code '-'} character, e.g., {@code `-v'}.
+ * GNU-style long
+ * (or mnemonic) options start with two dashes in a row, e.g., {@code `--file'}.
+ *
Picocli supports the POSIX convention that short options can be grouped, with the last option
+ * optionally taking a parameter, which may be attached to the option name or separated by a space or
+ * a {@code '='} character. The below examples are all equivalent:
+ *
+ * -xvfFILE
+ * -xvf FILE
+ * -xvf=FILE
+ * -xv --file FILE
+ * -xv --file=FILE
+ * -x -v --file FILE
+ * -x -v --file=FILE
+ *
+ * DOS
+ *
+ * DOS options mostly have upper case single-character names and start with a single slash {@code '/'} character.
+ * Option parameters are separated by a {@code ':'} character. Options cannot be grouped together but
+ * must be specified separately. For example:
+ *
+ * DIR /S /A:D /T:C
+ *
+ * PowerShell
+ *
+ * Windows PowerShell options generally are a word preceded by a single {@code '-'} character, e.g., {@code `-Help'}.
+ * Option parameters are separated by a space or by a {@code ':'} character.
+ *
+ * @return one or more option names
+ */
+ String[] names();
+
+ /**
+ * Indicates whether this option is required. By default this is false.
+ * If an option is required, but a user invokes the program without specifying the required option,
+ * a {@link MissingParameterException} is thrown from the {@link #parse(String...)} method.
+ * Required options that are part of a {@linkplain ArgGroup group} are required within the group, not required within the command:
+ * the group's {@linkplain ArgGroup#multiplicity() multiplicity} determines whether the group itself is required or optional.
+ * @return whether this option is required
+ */
+ boolean required() default false;
+
+ /**
+ * This should rarely be used: the recommended attributes are {@link #usageHelp() usageHelp} and {@link #versionHelp() versionHelp}.
+ *
+ * Only set {@code help=true} when this option should disable validation of the remaining
+ * arguments, and no error message should be generated for missing required options.
+ *
+ * This is useful for custom help options that are in addition to the standard help and
+ * version options. For example if your application has many hidden options or
+ * subcommands, and there is a custom help option like {@code --detailed-help} that prints
+ * the usage help message for these hidden options and subcommands.
+ *
+ * Note:
+ *
+ * Use the {@link #usageHelp() usageHelp} for "normal" help options (like {@code -h} and {@code --help} on unix,
+ * {@code -?} and {@code -Help} on Windows)
+ * and use {@link #versionHelp() versionHelp} for "normal" version help ({@code -V} and {@code --version} on unix,
+ * {@code -Version} on Windows):
+ * picocli has built-in logic so that options with {@code usageHelp=true} or {@code versionHelp=true}
+ * will automatically cause the requested help message to be printed in applications
+ * that use the {@link #execute(String...)} method, without any code in the application.
+ *
+ * Note that there is no such automatic help printing for options with {@code help=true};
+ * applications need to check whether the end user specified this option and take appropriate action
+ * in the business logic of the application.
+ *
+ * @return whether this option disables validation of the other arguments
+ */
+ boolean help() default false;
+
+ /**
+ * Set {@code usageHelp=true} for the {@code --help} option that triggers display of the usage help message.
+ * The convenience methods {@code Commandline.call},
+ * {@code Commandline.run}, and {@code Commandline.parseWithHandler(s)} will automatically print usage help
+ * when an option with {@code usageHelp=true} was specified on the command line.
+ *
+ * By default, all options and positional parameters are included in the usage help message
+ * except when explicitly marked {@linkplain #hidden() hidden}.
+ *
+ * If this option is specified on the command line, picocli will not validate the remaining arguments (so no "missing required
+ * option" errors) and the {@link CommandLine#isUsageHelpRequested()} method will return {@code true}.
+ *
+ * Alternatively, consider annotating your command with {@linkplain Command#mixinStandardHelpOptions() @Command(mixinStandardHelpOptions = true)}.
+ *
+ * @return whether this option allows the user to request usage help
+ * @since 0.9.8
+ * @see #hidden()
+ * @see #run(Runnable, String...)
+ * @see #call(Callable, String...)
+ * @see #parseWithHandler(IParseResultHandler2, String[])
+ * @see #printHelpIfRequested(List, PrintStream, PrintStream, Help.Ansi)
+ */
+ boolean usageHelp() default false;
+
+ /**
+ * Set {@code versionHelp=true} for the {@code --version} option that triggers display of the version information.
+ * The convenience methods {@code Commandline.call},
+ * {@code Commandline.run}, and {@code Commandline.parseWithHandler(s)} will automatically print version information
+ * when an option with {@code versionHelp=true} was specified on the command line.
+ *
+ * The version information string is obtained from the command's {@linkplain Command#version() version} annotation
+ * or from the {@linkplain Command#versionProvider() version provider}.
+ *
+ * If this option is specified on the command line, picocli will not validate the remaining arguments (so no "missing required
+ * option" errors) and the {@link CommandLine#isUsageHelpRequested()} method will return {@code true}.
+ *
+ * Alternatively, consider annotating your command with {@linkplain Command#mixinStandardHelpOptions() @Command(mixinStandardHelpOptions = true)}.
+ *
+ * @return whether this option allows the user to request version information
+ * @since 0.9.8
+ * @see #hidden()
+ * @see #run(Runnable, String...)
+ * @see #call(Callable, String...)
+ * @see #parseWithHandler(IParseResultHandler2, String[])
+ * @see #printHelpIfRequested(List, PrintStream, PrintStream, Help.Ansi)
+ */
+ boolean versionHelp() default false;
+
+ /**
+ * Description of this option, used when generating the usage documentation. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ *
+ * The description may contain variables that are rendered when help is requested.
+ * The string {@code ${DEFAULT-VALUE}} is replaced with the default value of the option. This is regardless of
+ * the command's {@link Command#showDefaultValues() showDefaultValues} setting or the option's {@link #showDefaultValue() showDefaultValue} setting.
+ * The string {@code ${COMPLETION-CANDIDATES}} is replaced with the completion candidates generated by
+ * {@link #completionCandidates()} in the description for this option.
+ * Also, embedded {@code %n} newline markers are converted to actual newlines.
+ *
+ * @return the description of this option
+ * @see Variable Interpolation section of the user manual
+ */
+ String[] description() default {};
+
+ /**
+ * Specifies the minimum number of required parameters and the maximum number of accepted parameters.
+ * If an option declares a positive arity, and the user specifies an insufficient number of parameters on the
+ * command line, a {@link MissingParameterException} is thrown by the {@link #parse(String...)} method.
+ *
+ * In many cases picocli can deduce the number of required parameters from the field's type.
+ * By default, flags (boolean options) have arity "0..1",
+ * and single-valued type fields (String, int, Integer, double, Double, File, Date, etc) have arity one.
+ * Generally, fields with types that cannot hold multiple values can omit the {@code arity} attribute.
+ *
+ * Fields used to capture options with arity two or higher should have a type that can hold multiple values,
+ * like arrays or Collections. See {@link #type()} for strongly-typed Collection fields.
+ *
+ * For example, if an option has 2 required parameters and any number of optional parameters,
+ * specify {@code @Option(names = "-example", arity = "2..*")}.
+ *
+ * A note on boolean options
+ *
+ * By default picocli allows boolean options (also called "flags" or "switches") to have an optional parameter,
+ * which must be either "true" or "false" (lowercase, other values are rejected).
+ * You can make a boolean option take a required parameter by annotating your field with {@code arity="1"}.
+ * For example:
+ * @Option(names = "-v", arity = "1") boolean verbose;
+ *
+ * Because this boolean field is defined with arity 1, the user must specify either {@code -v false}
+ * or {@code -v true}
+ * on the command line, or a {@link MissingParameterException} is thrown by the {@link #parse(String...)}
+ * method.
+ *
+ * To remove the optional parameter, define the field with {@code arity = "0"}.
+ * For example:
+ * @Option(names="-v", arity="0") boolean verbose;
+ * This will reject any of the below:
+ *
+ * -v true
+ * -v false
+ *
+ * @return how many arguments this option requires
+ */
+ String arity() default "";
+
+ /**
+ * Specify a {@code paramLabel} for the option parameter to be used in the usage help message. If omitted,
+ * picocli uses the field name in fish brackets ({@code '<'} and {@code '>'}) by default. Example:
+ * class Example {
+ * @Option(names = {"-o", "--output"}, paramLabel="FILE", description="path of the output file")
+ * private File out;
+ * @Option(names = {"-j", "--jobs"}, arity="0..1", description="Allow N jobs at once; infinite jobs with no arg.")
+ * private int maxJobs = -1;
+ * }
+ * By default, the above gives a usage help message like the following:
+ * Usage: <main class> [OPTIONS]
+ * -o, --output FILE path of the output file
+ * -j, --jobs [<maxJobs>] Allow N jobs at once; infinite jobs with no arg.
+ *
+ * @return name of the option parameter used in the usage help message
+ */
+ String paramLabel() default "";
+
+ /** Returns whether usage syntax decorations around the {@linkplain #paramLabel() paramLabel} should be suppressed.
+ * The default is {@code false}: by default, the paramLabel is surrounded with {@code '['} and {@code ']'} characters
+ * if the value is optional and followed by ellipses ("...") when multiple values can be specified.
+ * @since 3.6.0 */
+ boolean hideParamSyntax() default false;
+
+ /**
+ * Optionally specify a {@code type} to control exactly what Class the option parameter should be converted
+ * to. This may be useful when the field type is an interface or an abstract class. For example, a field can
+ * be declared to have type {@code java.lang.Number}, and annotating {@code @Option(type=Short.class)}
+ * ensures that the option parameter value is converted to a {@code Short} before setting the field value.
+ *
+ * For array fields whose component type is an interface or abstract class, specify the concrete component type.
+ * For example, a field with type {@code Number[]} may be annotated with {@code @Option(type=Short.class)}
+ * to ensure that option parameter values are converted to {@code Short} before adding an element to the array.
+ *
+ * Picocli will use the {@link ITypeConverter} that is
+ * {@linkplain #registerConverter(Class, ITypeConverter) registered} for the specified type to convert
+ * the raw String values before modifying the field value.
+ *
+ * Prior to 2.0, the {@code type} attribute was necessary for {@code Collection} and {@code Map} fields,
+ * but starting from 2.0 picocli will infer the component type from the generic type's type arguments.
+ * For example, for a field of type {@code Map} picocli will know the option parameter
+ * should be split up in key=value pairs, where the key should be converted to a {@code java.util.concurrent.TimeUnit}
+ * enum value, and the value should be converted to a {@code Long}. No {@code @Option(type=...)} type attribute
+ * is required for this. For generic types with wildcards, picocli will take the specified upper or lower bound
+ * as the Class to convert to, unless the {@code @Option} annotation specifies an explicit {@code type} attribute.
+ *
+ * If the field type is a raw collection or a raw map, and you want it to contain other values than Strings,
+ * or if the generic type's type arguments are interfaces or abstract classes, you may
+ * specify a {@code type} attribute to control the Class that the option parameter should be converted to.
+ * @return the type(s) to convert the raw String values
+ */
+ Class>[] type() default {};
+
+ /**
+ * Optionally specify one or more {@link ITypeConverter} classes to use to convert the command line argument into
+ * a strongly typed value (or key-value pair for map fields). This is useful when a particular field should
+ * use a custom conversion that is different from the normal conversion for the field's type.
+ *
For example, for a specific field you may want to use a converter that maps the constant names defined
+ * in {@link java.sql.Types java.sql.Types} to the {@code int} value of these constants, but any other {@code int} fields should
+ * not be affected by this and should continue to use the standard int converter that parses numeric values.
+ * @return the type converter(s) to use to convert String values to strongly typed values for this field
+ * @see CommandLine#registerConverter(Class, ITypeConverter)
+ */
+ Class extends ITypeConverter>>[] converter() default {};
+
+ /**
+ * Specify a regular expression to use to split option parameter values before applying them to the field.
+ * All elements resulting from the split are added to the array or Collection. Previously ignored for single-value fields,
+ * from picocli 4.0 a {@code split} regex can only be specified on multi-value options and positional parameters.
+ * @return a regular expression to split option parameter values or {@code ""} if the value should not be split
+ * @see String#split(String)
+ */
+ String split() default "";
+
+ /**
+ * Specify the string to display for the {@link #split split} regular expression in the usage help synopsis.
+ * @since 4.3 */
+ String splitSynopsisLabel() default "";
+
+ /**
+ * Set {@code hidden=true} if this option should not be included in the usage help message.
+ * @return whether this option should be excluded from the usage documentation
+ */
+ boolean hidden() default false;
+
+ /** Returns the default value of this option, before splitting and type conversion.
+ * To get a {@code null} default value, omit specifying a default value or use the special value {@link Option#NULL_VALUE} -
+ * for options of type {@code Optional} that will result in the {@code Optional.empty()}
+ * value being assigned when the option is not specified on the command line.
+ * @return a String that (after type conversion) will be used as the value for this option if the option was not specified on the command line
+ * @see #fallbackValue()
+ * @since 3.2 */
+ String defaultValue() default "__no_default_value__";
+
+ /** Use this attribute to control for a specific option whether its default value should be shown in the usage
+ * help message. If not specified, the default value is only shown when the {@link Command#showDefaultValues()}
+ * is set {@code true} on the command. Use this attribute to specify whether the default value
+ * for this specific option should always be shown or never be shown, regardless of the command setting.
+ * Note that picocli 3.2 allows {@linkplain #description() embedding default values} by specifying the variable
+ * {@code ${DEFAULT-VALUE}} anywhere in the description that ignores this setting.
+ * @return whether this option's default value should be shown in the usage help message
+ */
+ Help.Visibility showDefaultValue() default Help.Visibility.ON_DEMAND;
+
+ /** Use this attribute to specify an {@code Iterable} class that generates completion candidates for this option.
+ * For map fields, completion candidates should be in {@code key=value} form.
+ *
+ * Completion candidates are used in bash completion scripts generated by the {@code picocli.AutoComplete} class.
+ * Bash has special completion options to generate file names and host names, and the bash completion scripts
+ * generated by {@code AutoComplete} delegate to these bash built-ins for {@code @Options} whose {@code type} is
+ * {@code java.io.File}, {@code java.nio.file.Path} or {@code java.net.InetAddress}.
+ *
+ * For {@code @Options} whose {@code type} is a Java {@code enum}, {@code AutoComplete} can generate completion
+ * candidates from the type. For other types, use this attribute to specify completion candidates.
+ *
+ *
+ * @return a class whose instances can iterate over the completion candidates for this option
+ * @see io.mosn.coder.cli.CommandLine.IFactory
+ * @since 3.2 */
+ Class extends Iterable> completionCandidates() default NoCompletionCandidates.class;
+
+ /**
+ * Set {@code interactive=true} to make this option prompt the end user for a value (like a password).
+ * Only supported for single-value options and {@code char[]} arrays (no collections, maps or other array types).
+ * When running on Java 6 or greater and {@link Option#echo() echo = false} (the default),
+ * this will use the {@link Console#readPassword()} API to get a value without echoing input to the console,
+ * otherwise it will simply read a value from {@code System.in}.
+ *
+ * For passwords, best security practice is to use type {@code char[]} instead of {@code String}, and to to null out the array after use.
+ *
+ * When defined with {@code arity = "0..1"}, the option can also take a value from the command line.
+ * (The user will still be prompted if no option parameter was specified on the command line.)
+ * This is useful for commands that need to be run interactively as well as in batch mode.
+ *
+ * @return whether this option prompts the end user for a value to be entered on the command line
+ * @since 3.5
+ */
+ boolean interactive() default false;
+
+ /** Use this attribute to control whether user input for an interactive option is echoed to the console or not.
+ * If {@code echo = true}, the user input is echoed to the console.
+ * This attribute is ignored when {@code interactive = false} (the default).
+ * @return whether the user input for an interactive option should be echoed to the console or not
+ * @see OptionSpec#echo()
+ * @since 4.6 */
+ boolean echo() default false;
+
+ /** Use this attribute to customize the text displayed to the end user for an interactive option when asking for user input.
+ * When omitted, the displayed text is derived from the option name and the first description line.
+ * This attribute is ignored when {@code interactive = false} (the default).
+ * @return the text to display to the end user for an interactive option when asking for user input
+ * @see OptionSpec#prompt()
+ * @since 4.6 */
+ String prompt() default "";
+
+ /** ResourceBundle key for this option. If not specified, (and a ResourceBundle {@linkplain Command#resourceBundle() exists for this command}) an attempt
+ * is made to find the option description using any of the option names (without leading hyphens) as key.
+ * @see OptionSpec#description()
+ * @since 3.6
+ */
+ String descriptionKey() default "";
+
+ /**
+ * When {@link Command#sortOptions() @Command(sortOptions = false)} is specified, this attribute can be used to control the order in which options are listed in the usage help message.
+ * When {@link Command#sortSynopsis() @Command(sortSynopsis = false)} is specified, this attribute controls the order in which options appear in the synopsis of the usage help message.
+ * @return the position in the options list at which this option should be shown. Options with a lower number are shown before options with a higher number. Gaps are allowed.
+ * @since 3.9
+ */
+ int order() default -1;
+
+ /** (Only for boolean options): set this to automatically add a negative version for this boolean option.
+ * For example, for a {@code --force} option the negative version would be {@code --no-force},
+ * and for a {@code -XX:+PrintGCDetails} option, the negative version would be {@code -XX:-PrintGCDetails}.
+ * The synopsis would show {@code --[no-]force} and {@code -XX:(+|-)PrintGCDetails}, respectively.
+ * The form of the negative name can be customized by modifying the regular expressions
+ * used by {@linkplain RegexTransformer#createDefault() default}, or by replacing the default
+ * {@link INegatableOptionTransformer} with a custom implementation entirely.
+ * Negative option names used to parse the command line are collected when the command is constructed
+ * (so any variables in the option names will be resolved at that time).
+ * Documentation strings for negatable options are generated on demand when the usage help message is shown.
+ * @see CommandLine#getNegatableOptionTransformer()
+ * @see CommandLine#setNegatableOptionTransformer(INegatableOptionTransformer)
+ * @since 4.0 */
+ boolean negatable() default false;
+
+ /** Determines on which command(s) this option exists: on this command only (the default), or
+ * whether this is a "global" option that is applied to this command and all subcommands, sub-subcommands, etc.
+ * @since 4.3
+ */
+ ScopeType scope() default ScopeType.LOCAL;
+ /**
+ * For options with an optional parameter (for example, {@code arity = "0..1"}), this value is assigned to the annotated element
+ * if the option is specified on the command line without an option parameter.
+ *
+ * This is different from the {@link #defaultValue()}, which is assigned if the option is not specified at all on the command line.
+ *
+ * Using a {@code fallbackValue} allows applications to distinguish between
+ *
+ * - option was not specified on the command line (default value assigned)
+ * - option was specified without parameter on the command line (fallback value assigned)
+ * - option was specified with parameter on the command line (command line argument value assigned)
+ *
+ * This is useful to define options that can function as a boolean "switch"
+ * and optionally allow users to provide a (strongly typed) extra parameter value.
+ *
+ * Use the special value {@link Option#NULL_VALUE} to specify {@code null} -
+ * for options of type {@code Optional} that will result in the {@code Optional.empty()}
+ * value being assigned when the option name is specified without a parameter on the command line.
+ * @see OptionSpec#fallbackValue()
+ * @since 4.0 */
+ String fallbackValue() default "";
+
+ /** For options of type Map, setting the {@code mapFallbackValue} to any value allows end user
+ * to specify key-only parameters for this option. For example, {@code -Dkey} instead of {@code -Dkey=value}.
+ * The value specified in this annotation is the value that is put into the Map for the user-specified key.
+ * Use the special value {@link Option#NULL_VALUE} to specify {@code null} -
+ * for maps of type {@code Map>} that will result in {@code Optional.empty()}
+ * values in the map when only the key is specified.
+ * If no {@code mapFallbackValue} is set, key-only Map parameters like {@code -Dkey}
+ * are considered invalid user input and cause a {@link ParameterException} to be thrown.
+ * @see ArgSpec#mapFallbackValue()
+ * @since 4.6 */
+ String mapFallbackValue() default ArgSpec.UNSPECIFIED;
+
+ /**
+ * Optionally specify a custom {@code IParameterConsumer} to temporarily suspend picocli's parsing logic
+ * and process one or more command line arguments in a custom manner.
+ * This may be useful when passing arguments through to another program.
+ * @since 4.0 */
+ Class extends IParameterConsumer> parameterConsumer() default NullParameterConsumer.class;
+
+ /** Returns the preprocessor for this option.
+ * @see IParameterPreprocessor
+ * @since 4.6 */
+ Class extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;
+ }
+ /**
+ *
+ * Fields annotated with {@code @Parameters} will be initialized with positional parameters. By specifying the
+ * {@link #index()} attribute you can pick the exact position or a range of positional parameters to apply. If no
+ * index is specified, the field will get all positional parameters (and so it should be an array or a collection).
+ *
+ * In the case of command methods (annotated with {@code @Command}), method parameters may be annotated with {@code @Parameters},
+ * but are are considered positional parameters by default, unless they are annotated with {@code @Option}.
+ *
+ * Command class example:
+ *
+ *
+ * import static io.mosn.coder.cli.CommandLine.*;
+ *
+ * public class MyCalcParameters {
+ * @Parameters(description = "Any number of input numbers")
+ * private List<BigDecimal> files = new ArrayList<BigDecimal>();
+ *
+ * @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display this help and exit")
+ * private boolean help;
+ * }
+ *
+ * A field cannot be annotated with both {@code @Parameters} and {@code @Option} or a {@code ParameterException}
+ * is thrown.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+ public @interface Parameters {
+ /** Special value that can be used in some annotation attributes to designate {@code null}.
+ * @see Parameters#defaultValue()
+ * @see Parameters#mapFallbackValue()
+ * @since 4.6 */
+ public static final String NULL_VALUE = ArgSpec.NULL_VALUE;
+ /** Specify an index ("0", or "1", etc.) to pick which of the command line arguments should be assigned to this
+ * field. For array or Collection fields, you can also specify an index range ("0..3", or "2..*", etc.) to assign
+ * a subset of the command line arguments to this field. The default is "*", meaning all command line arguments.
+ * @return an index or range specifying which of the command line arguments should be assigned to this field
+ */
+ String index() default "";
+
+ /** Description of the parameter(s), used when generating the usage documentation. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ *
+ * The description may contain variables that are rendered when help is requested.
+ * The string {@code ${DEFAULT-VALUE}} is replaced with the default value of the positional parameter. This is regardless of
+ * the command's {@link Command#showDefaultValues() showDefaultValues} setting or the positional parameter's {@link #showDefaultValue() showDefaultValue} setting.
+ * The string {@code ${COMPLETION-CANDIDATES}} is replaced with the completion candidates generated by
+ * {@link #completionCandidates()} in the description for this positional parameter.
+ * Also, embedded {@code %n} newline markers are converted to actual newlines.
+ *
+ * @return the description of the parameter(s)
+ * @see Variable Interpolation section of the user manual
+ */
+ String[] description() default {};
+
+ /**
+ * Specifies the minimum number of required parameters and the maximum number of accepted parameters. If a
+ * positive arity is declared, and the user specifies an insufficient number of parameters on the command line,
+ * {@link MissingParameterException} is thrown by the {@link #parse(String...)} method.
+ * The default depends on the type of the parameter: booleans require no parameters, arrays and Collections
+ * accept zero to any number of parameters, and any other type accepts one parameter.
+ * For single-value parameters, setting {@code arity = "0..1"} makes a positional parameter optional, while setting {@code arity = "1"} makes it required.
+ * Required parameters that are part of a {@linkplain ArgGroup group} are required within the group, not required within the command:
+ * the group's {@linkplain ArgGroup#multiplicity() multiplicity} determines whether the group itself is required or optional.
+ * @return the range of minimum and maximum parameters accepted by this command
+ */
+ String arity() default "";
+
+ /**
+ * Specify a {@code paramLabel} for the parameter to be used in the usage help message. If omitted,
+ * picocli uses the field name in fish brackets ({@code '<'} and {@code '>'}) by default. Example:
+ * class Example {
+ * @Parameters(paramLabel="FILE", description="path of the input FILE(s)")
+ * private File[] inputFiles;
+ * }
+ * By default, the above gives a usage help message like the following:
+ * Usage: <main class> [FILE...]
+ * [FILE...] path of the input FILE(s)
+ *
+ * @return name of the positional parameter used in the usage help message
+ */
+ String paramLabel() default "";
+
+ /** Returns whether usage syntax decorations around the {@linkplain #paramLabel() paramLabel} should be suppressed.
+ * The default is {@code false}: by default, the paramLabel is surrounded with {@code '['} and {@code ']'} characters
+ * if the value is optional and followed by ellipses ("...") when multiple values can be specified.
+ * @since 3.6.0 */
+ boolean hideParamSyntax() default false;
+
+ /**
+ *
+ * Optionally specify a {@code type} to control exactly what Class the positional parameter should be converted
+ * to. This may be useful when the field type is an interface or an abstract class. For example, a field can
+ * be declared to have type {@code java.lang.Number}, and annotating {@code @Parameters(type=Short.class)}
+ * ensures that the positional parameter value is converted to a {@code Short} before setting the field value.
+ *
+ * For array fields whose component type is an interface or abstract class, specify the concrete component type.
+ * For example, a field with type {@code Number[]} may be annotated with {@code @Parameters(type=Short.class)}
+ * to ensure that positional parameter values are converted to {@code Short} before adding an element to the array.
+ *
+ * Picocli will use the {@link ITypeConverter} that is
+ * {@linkplain #registerConverter(Class, ITypeConverter) registered} for the specified type to convert
+ * the raw String values before modifying the field value.
+ *
+ * Prior to 2.0, the {@code type} attribute was necessary for {@code Collection} and {@code Map} fields,
+ * but starting from 2.0 picocli will infer the component type from the generic type's type arguments.
+ * For example, for a field of type {@code Map} picocli will know the positional parameter
+ * should be split up in key=value pairs, where the key should be converted to a {@code java.util.concurrent.TimeUnit}
+ * enum value, and the value should be converted to a {@code Long}. No {@code @Parameters(type=...)} type attribute
+ * is required for this. For generic types with wildcards, picocli will take the specified upper or lower bound
+ * as the Class to convert to, unless the {@code @Parameters} annotation specifies an explicit {@code type} attribute.
+ *
+ * If the field type is a raw collection or a raw map, and you want it to contain other values than Strings,
+ * or if the generic type's type arguments are interfaces or abstract classes, you may
+ * specify a {@code type} attribute to control the Class that the positional parameter should be converted to.
+ * @return the type(s) to convert the raw String values
+ */
+ Class>[] type() default {};
+
+ /**
+ * Optionally specify one or more {@link ITypeConverter} classes to use to convert the command line argument into
+ * a strongly typed value (or key-value pair for map fields). This is useful when a particular field should
+ * use a custom conversion that is different from the normal conversion for the field's type.
+ *
For example, for a specific field you may want to use a converter that maps the constant names defined
+ * in {@link java.sql.Types java.sql.Types} to the {@code int} value of these constants, but any other {@code int} fields should
+ * not be affected by this and should continue to use the standard int converter that parses numeric values.
+ * @return the type converter(s) to use to convert String values to strongly typed values for this field
+ * @see CommandLine#registerConverter(Class, ITypeConverter)
+ */
+ Class extends ITypeConverter>>[] converter() default {};
+
+ /**
+ * Specify a regular expression to use to split positional parameter values before applying them to the field.
+ * All elements resulting from the split are added to the array or Collection. Previously ignored for single-value fields,
+ * from picocli 4.0 a {@code split} regex can only be specified on multi-value options and positional parameters.
+ * @return a regular expression to split operand values or {@code ""} if the value should not be split
+ * @see String#split(String)
+ */
+ String split() default "";
+
+ /**
+ * Specify a string to show the split option parameter values in usage
+ * @since 4.3
+ */
+ String splitSynopsisLabel() default "";
+
+ /**
+ * Set {@code hidden=true} if this parameter should not be included in the usage message.
+ * @return whether this parameter should be excluded from the usage message
+ */
+ boolean hidden() default false;
+
+ /** Returns the default value of this positional parameter, before splitting and type conversion.
+ * To get a {@code null} default value, omit specifying a default value or use the special value {@link Parameters#NULL_VALUE} -
+ * for positional parameters of type {@code Optional} that will result in the {@code Optional.empty()}
+ * value being assigned when the positional parameters is not specified on the command line.
+ * @return a String that (after type conversion) will be used as the value for this positional parameter if no value was specified on the command line
+ * @since 3.2 */
+ String defaultValue() default "__no_default_value__";
+
+ /** Use this attribute to control for a specific positional parameter whether its default value should be shown in the usage
+ * help message. If not specified, the default value is only shown when the {@link Command#showDefaultValues()}
+ * is set {@code true} on the command. Use this attribute to specify whether the default value
+ * for this specific positional parameter should always be shown or never be shown, regardless of the command setting.
+ * Note that picocli 3.2 allows {@linkplain #description() embedding default values} by specifying the variable
+ * {@code ${DEFAULT-VALUE}} anywhere in the description that ignores this setting.
+ * @return whether this positional parameter's default value should be shown in the usage help message
+ */
+ Help.Visibility showDefaultValue() default Help.Visibility.ON_DEMAND;
+
+ /** Use this attribute to specify an {@code Iterable} class that generates completion candidates for
+ * this positional parameter. For map fields, completion candidates should be in {@code key=value} form.
+ *
+ * Completion candidates are used in bash completion scripts generated by the {@code picocli.AutoComplete} class.
+ * Unfortunately, {@code picocli.AutoComplete} is not very good yet at generating completions for positional parameters.
+ *
+ *
+ * @return a class whose instances can iterate over the completion candidates for this positional parameter
+ * @see io.mosn.coder.cli.CommandLine.IFactory
+ * @since 3.2 */
+ Class extends Iterable> completionCandidates() default NoCompletionCandidates.class;
+
+ /**
+ * Set {@code interactive=true} if this positional parameter will prompt the end user for a value (like a password).
+ * Only supported for single-value positional parameters (not arrays, collections or maps).
+ * When running on Java 6 or greater and {@link Option#echo() echo = false} (the default),
+ * this will use the {@link Console#readPassword()} API to get a value without echoing input to the console,
+ * otherwise it will simply read a value from {@code System.in}.
+ * @return whether this positional parameter prompts the end user for a value to be entered on the command line
+ * @since 3.5
+ */
+ boolean interactive() default false;
+
+ /** Use this attribute to control whether user input for an interactive positional parameter is echoed to the console or not.
+ * If {@code echo = true}, the user input is echoed to the console.
+ * This attribute is ignored when {@code interactive = false} (the default).
+ * @return whether the user input for an interactive positional parameter should be echoed to the console or not
+ * @see PositionalParamSpec#echo()
+ * @since 4.6 */
+ boolean echo() default false;
+
+ /** Use this attribute to customize the text displayed to the end user for an interactive positional parameter when asking for user input.
+ * When omitted, the displayed text is derived from the positional parameter's
+ * position (index) and the first description line.
+ * This attribute is ignored when {@code interactive = false} (the default).
+ * @return the text to display to the end user for an interactive positional parameter when asking for user input
+ * @see PositionalParamSpec#prompt()
+ * @since 4.6 */
+ String prompt() default "";
+
+ /** ResourceBundle key for this option. If not specified, (and a ResourceBundle {@linkplain Command#resourceBundle() exists for this command}) an attempt
+ * is made to find the positional parameter description using {@code paramLabel() + "[" + index() + "]"} as key.
+ *
+ * @see PositionalParamSpec#description()
+ * @since 3.6
+ */
+ String descriptionKey() default "";
+
+ /** Determines on which command(s) this positional parameter exists: on this command only (the default), or
+ * whether this is a "global" parameter that is applied to this command and all subcommands, sub-subcommands, etc.
+ * @since 4.3
+ */
+ ScopeType scope() default ScopeType.LOCAL;
+ /**
+ * Optionally specify a custom {@code IParameterConsumer} to temporarily suspend picocli's parsing logic
+ * and process one or more command line arguments in a custom manner.
+ * @since 4.0 */
+ Class extends IParameterConsumer> parameterConsumer() default NullParameterConsumer.class;
+
+ /** For positional parameters of type Map, setting the {@code mapFallbackValue} to any value allows end user
+ * to specify key-only parameters for this parameter. For example, {@code key} instead of {@code key=value}.
+ * The value specified in this annotation is the value that is put into the Map for the user-specified key.
+ * Use the special value {@link Parameters#NULL_VALUE} to specify {@code null} -
+ * for maps of type {@code Map>} that will result in {@code Optional.empty()}
+ * values in the map when only the key is specified.
+ * If no {@code mapFallbackValue} is set, key-only Map parameters like {@code -Dkey}
+ * are considered invalid user input and cause a {@link ParameterException} to be thrown.
+ * @see ArgSpec#mapFallbackValue()
+ * @since 4.6 */
+ String mapFallbackValue() default ArgSpec.UNSPECIFIED;
+
+ /** Returns the preprocessor for this positional parameter.
+ * @see IParameterPreprocessor
+ * @since 4.6 */
+ Class extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;
+ }
+
+ /**
+ *
+ * Fields annotated with {@code @ParentCommand} will be initialized with the parent command of the current subcommand.
+ * If the current command does not have a parent command, this annotation has no effect.
+ *
+ * Parent commands often define options that apply to all the subcommands.
+ * This annotation offers a convenient way to inject a reference to the parent command into a subcommand, so the
+ * subcommand can access its parent options. For example:
+ *
+ * @Command(name = "top", subcommands = Sub.class)
+ * class Top implements Runnable {
+ *
+ * @Option(names = {"-d", "--directory"}, description = "this option applies to all subcommands")
+ * File baseDirectory;
+ *
+ * public void run() { System.out.println("Hello from top"); }
+ * }
+ *
+ * @Command(name = "sub")
+ * class Sub implements Runnable {
+ *
+ * @ParentCommand
+ * private Top parent;
+ *
+ * public void run() {
+ * System.out.println("Subcommand: parent command 'directory' is " + parent.baseDirectory);
+ * }
+ * }
+ *
+ * @since 2.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface ParentCommand { }
+
+ /**
+ * Fields annotated with {@code @Unmatched} will be initialized with the list of unmatched command line arguments, if any.
+ * If this annotation is found, picocli automatically sets {@linkplain CommandLine#setUnmatchedArgumentsAllowed(boolean) unmatchedArgumentsAllowed} to {@code true}.
+ * @see CommandLine#isUnmatchedArgumentsAllowed()
+ * @since 3.0
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Unmatched { }
+
+ /**
+ *
+ * Fields annotated with {@code @Mixin} are "expanded" into the current command: {@link Option @Option} and
+ * {@link Parameters @Parameters} in the mixin class are added to the options and positional parameters of this command.
+ * A {@link DuplicateOptionAnnotationsException} is thrown if any of the options in the mixin has the same name as
+ * an option in this command.
+ *
+ * The {@code Mixin} annotation provides a way to reuse common options and parameters without subclassing. For example:
+ *
+ * @Command(name="HelloWorld")
+ * class HelloWorld implements Runnable {
+ *
+ * // adds the --help and --version options to this command
+ * @Mixin
+ * private HelpOptions options = new HelpOptions();
+ *
+ * @Option(names = {"-u", "--userName"}, required = true, description = "The user name")
+ * String userName;
+ *
+ * public void run() { System.out.println("Hello, " + userName); }
+ * }
+ *
+ * // Common reusable help options.
+ * class HelpOptions {
+ *
+ * @Option(names = { "-h", "--help"}, usageHelp = true, description = "Display this help and exit")
+ * private boolean help;
+ *
+ * @Option(names = { "-V", "--version"}, versionHelp = true, description = "Display version info and exit")
+ * private boolean versionHelp;
+ * }
+ *
+ * @since 3.0
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.FIELD, ElementType.PARAMETER})
+ public @interface Mixin {
+ /** Optionally specify a name that the mixin object can be retrieved with from the {@code CommandSpec}.
+ * If not specified the name of the annotated field is used.
+ * @return a String to register the mixin object with, or an empty String if the name of the annotated field should be used */
+ String name() default "";
+ }
+ /**
+ * Fields annotated with {@code @Spec} will be initialized with the {@code CommandSpec} for the command the field is part of. Example usage:
+ *
+ * class InjectSpecExample implements Runnable {
+ * @Spec CommandSpec commandSpec;
+ * //...
+ * public void run() {
+ * // do something with the injected objects
+ * }
+ * }
+ *
+ * @since 3.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.FIELD, ElementType.METHOD})
+ public @interface Spec {
+ /** Identifies what kind of {@code CommandSpec} should be injected.
+ * @since 4.3.0 */
+ enum Target {
+ /** Injects the {@code CommandSpec} of the command where this {@code @Spec}-annotated program element is declared. */
+ SELF,
+ /** Injects the {@code CommandSpec} of the "mixee" command that receives the options and other command elements defined here,
+ * or {@code null} if this commands is not {@linkplain Mixin mixed into} another command.
+ * The "mixee" command has a {@code @Mixin}-annotated program element with the type of the class where this {@code @Spec}-annotated program element is declared. */
+ MIXEE}
+
+ /** Whether to inject the {@code CommandSpec} of this command (the default) or the {@code CommandSpec}
+ * of the "mixee" command that receives the options and other command elements defined here.
+ * @see Mixin
+ * @since 4.3.0 */
+ Target value() default Target.SELF;
+ }
+
+ /**
+ * Annotate your class with {@code @Command} when you want more control over the format of the generated help
+ * message. From 3.6, methods can also be annotated with {@code @Command}, where the method parameters define the
+ * command options and positional parameters.
+ *
+ * @Command(name = "Encrypt", mixinStandardHelpOptions = true,
+ * description = "Encrypt FILE(s), or standard input, to standard output or to the output file.",
+ * version = "Encrypt version 1.0",
+ * footer = "Copyright (c) 2017",
+ * exitCodeListHeading = "Exit Codes:%n",
+ * exitCodeList = { " 0:Successful program execution.",
+ * "64:Invalid input: an unknown option or invalid parameter was specified.",
+ * "70:Execution exception: an exception occurred while executing the business logic."}
+ * )
+ * public class Encrypt {
+ * @Parameters(paramLabel = "FILE", description = "Any number of input files")
+ * private List<File> files = new ArrayList<File>();
+ *
+ * @Option(names = { "-o", "--out" }, description = "Output file (default: print to console)")
+ * private File outputFile;
+ *
+ * @Option(names = { "-v", "--verbose"}, description = "Verbose mode. Helpful for troubleshooting. Multiple -v options increase the verbosity.")
+ * private boolean[] verbose;
+ * }
+ *
+ * The structure of a help message looks like this:
+ *
+ * - [header]
+ * - [synopsis]: {@code Usage: [OPTIONS] [FILE...]}
+ * - [description]
+ * - [parameter list]: {@code [FILE...] Any number of input files}
+ * - [option list]: {@code -h, --help prints this help message and exits}
+ * - [exit code list]
+ * - [footer]
+ *
*/
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.TYPE, ElementType.LOCAL_VARIABLE, ElementType.FIELD, ElementType.PACKAGE, ElementType.METHOD})
+ public @interface Command {
+ /** Program name to show in the synopsis. If omitted, {@code ""} is used.
+ * For {@linkplain #subcommands() declaratively added} subcommands, this attribute is also used
+ * by the parser to recognize subcommands in the command line arguments.
+ * @return the program name to show in the synopsis
+ * @see CommandSpec#name()
+ * @see Help#commandName() */
+ String name() default CommandSpec.DEFAULT_COMMAND_NAME;
+
+ /** Alternative command names by which this subcommand is recognized on the command line.
+ * @return one or more alternative command names
+ * @since 3.1 */
+ String[] aliases() default {};
+
+ /** A list of classes to instantiate and register as subcommands. When registering subcommands declaratively
+ * like this, you don't need to call the {@link CommandLine#addSubcommand(String, Object)} method. For example, this:
+ *
+ * @Command(subcommands = {
+ * GitStatus.class,
+ * GitCommit.class,
+ * GitBranch.class })
+ * public class Git { ... }
+ *
+ * CommandLine commandLine = new CommandLine(new Git());
+ *
is equivalent to this:
+ *
+ * // alternative: programmatically add subcommands.
+ * // NOTE: in this case there should be no `subcommands` attribute on the @Command annotation.
+ * @Command public class Git { ... }
+ *
+ * CommandLine commandLine = new CommandLine(new Git())
+ * .addSubcommand("status", new GitStatus())
+ * .addSubcommand("commit", new GitCommit())
+ * .addSubcommand("branch", new GitBranch());
+ *
+ * Applications may be interested in the following built-in commands in picocli
+ * that can be used as subcommands:
+ *
+ * - {@link HelpCommand} - a {@code help} subcommand that prints help on the following or preceding command
+ * - @link AutoComplete.GenerateCompletion - a {@code generate-completion} subcommand that prints a Bash/ZSH completion script for its parent command, so that clients can install autocompletion in one line by running {@code source <(parent-command generate-completion)} in the shell
+ *
+ * @return the declaratively registered subcommands of this command, or an empty array if none
+ * @see CommandLine#addSubcommand(String, Object)
+ * @see HelpCommand
+ * @since 0.9.8
+ */
+ Class>[] subcommands() default {};
+
+ /** Returns whether the subcommands of this command are repeatable, that is, whether such subcommands can
+ * occur multiple times and may be followed by sibling commands instead of only by child commands of the subcommand.
+ * @since 4.2 */
+ boolean subcommandsRepeatable() default false;
+
+ /** Specify whether methods annotated with {@code @Command} should be registered as subcommands of their
+ * enclosing {@code @Command} class.
+ * The default is {@code true}. For example:
+ *
+ * @Command
+ * public class Git {
+ * @Command
+ * void status() { ... }
+ * }
+ *
+ * CommandLine git = new CommandLine(new Git());
+ *
is equivalent to this:
+ *
+ * // don't add command methods as subcommands automatically
+ * @Command(addMethodSubcommands = false)
+ * public class Git {
+ * @Command
+ * void status() { ... }
+ * }
+ *
+ * // add command methods as subcommands programmatically
+ * CommandLine git = new CommandLine(new Git());
+ * CommandLine status = new CommandLine(CommandLine.getCommandMethods(Git.class, "status").get(0));
+ * git.addSubcommand("status", status);
+ *
+ * @return whether methods annotated with {@code @Command} should be registered as subcommands
+ * @see CommandLine#addSubcommand(String, Object)
+ * @see CommandLine#getCommandMethods(Class, String)
+ * @see CommandSpec#addMethodSubcommands()
+ * @since 3.6.0 */
+ boolean addMethodSubcommands() default true;
+
+ /** String that separates options from option parameters. Default is {@code "="}. Spaces are also accepted.
+ * @return the string that separates options from option parameters, used both when parsing and when generating usage help
+ * @see CommandLine#setSeparator(String) */
+ String separator() default "=";
+
+ /** Version information for this command, to print to the console when the user specifies an
+ * {@linkplain Option#versionHelp() option} to request version help. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * This is not part of the usage help message.
+ *
+ * @return a string or an array of strings with version information about this command (each string in the array is displayed on a separate line).
+ * @since 0.9.8
+ * @see CommandLine#printVersionHelp(PrintStream)
+ */
+ String[] version() default {};
+
+ /** Class that can provide version information dynamically at runtime. An implementation may return version
+ * information obtained from the JAR manifest, a properties file or some other source.
+ * @return a Class that can provide version information dynamically at runtime
+ * @since 2.2 */
+ Class extends IVersionProvider> versionProvider() default NoVersionProvider.class;
+
+ /**
+ * Adds the standard {@code -h} and {@code --help} {@linkplain Option#usageHelp() usageHelp} options and {@code -V}
+ * and {@code --version} {@linkplain Option#versionHelp() versionHelp} options to the options of this command.
+ *
+ * Note that if no {@link #version()} or {@link #versionProvider()} is specified, the {@code --version} option will not print anything.
+ *
+ * For {@linkplain #resourceBundle() internationalization}: the help option has {@code descriptionKey = "mixinStandardHelpOptions.help"},
+ * and the version option has {@code descriptionKey = "mixinStandardHelpOptions.version"}.
+ *
+ * @return whether the auto-help mixin should be added to this command
+ * @since 3.0 */
+ boolean mixinStandardHelpOptions() default false;
+
+ /** Set this attribute to {@code true} if this subcommand is a help command, and required options and positional
+ * parameters of the parent command should not be validated. If a subcommand marked as {@code helpCommand} is
+ * specified on the command line, picocli will not validate the parent arguments (so no "missing required
+ * option" errors) and the {@link CommandLine#printHelpIfRequested(List, PrintStream, PrintStream, Help.Ansi)} method will return {@code true}.
+ * @return {@code true} if this subcommand is a help command and picocli should not check for missing required
+ * options and positional parameters on the parent command
+ * @since 3.0 */
+ boolean helpCommand() default false;
+
+ /** Set the heading preceding the header section.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the header section
+ * @see UsageMessageSpec#headerHeading()
+ * @see Help#headerHeading(Object...) */
+ String headerHeading() default "";
+
+ /** Optional summary description of the command, shown before the synopsis. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return summary description of the command
+ * @see UsageMessageSpec#header()
+ * @see Help#header(Object...) */
+ String[] header() default {};
+
+ /** Set the heading preceding the synopsis text. The default heading is {@code "Usage: "} (without a line break between the heading and the synopsis text).
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the synopsis text
+ * @see Help#synopsisHeading(Object...) */
+ String synopsisHeading() default "Usage: ";
+
+ /** Specify {@code true} to generate an abbreviated synopsis like {@code " [OPTIONS] [PARAMETERS...] [COMMAND]"}.
+ * By default, a detailed synopsis with individual option names and parameters is generated.
+ * @return whether the synopsis should be abbreviated
+ * @see Help#abbreviatedSynopsis()
+ * @see Help#detailedSynopsis(int, Comparator, boolean) */
+ boolean abbreviateSynopsis() default false;
+
+ /** Specify one or more custom synopsis lines to display instead of an auto-generated synopsis. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return custom synopsis text to replace the auto-generated synopsis
+ * @see Help#customSynopsis(Object...) */
+ String[] customSynopsis() default {};
+
+ /**
+ * Specify the String to show in the synopsis for the subcommands of this command. The default is
+ * {@code "[COMMAND]"}. Ignored if this command has no {@linkplain #subcommands() subcommands}.
+ * @since 4.0
+ */
+ String synopsisSubcommandLabel() default "[COMMAND]";
+
+ /** Set the heading preceding the description section.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the description section
+ * @see Help#descriptionHeading(Object...) */
+ String descriptionHeading() default "";
+
+ /** Optional text to display between the synopsis line(s) and the list of options. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return description of this command
+ * @see Help#description(Object...) */
+ String[] description() default {};
+
+ /** Set the heading preceding the parameters list.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the parameters list
+ * @see Help#parameterListHeading(Object...) */
+ String parameterListHeading() default "";
+
+ /** Set the heading preceding the options list.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the options list
+ * @see Help#optionListHeading(Object...) */
+ String optionListHeading() default "";
+
+ /** Specify {@code false} to show Options in declaration order in the option list of the usage help message (or to sort options by their {@linkplain Option#order() order index} if set).
+ * Note that picocli cannot reliably detect declaration order in commands that have both {@code @Option}-annotated methods and {@code @Option}-annotated fields.
+ * The default ({@code true}) is to sort alphabetically.
+ * @return whether options should be shown in alphabetic order. */
+ boolean sortOptions() default true;
+
+ /** Specify {@code false} to show options in declaration order in the synopsis of the usage help message (or to sort options by their {@linkplain Option#order() order index} if set).
+ * Note that picocli cannot reliably detect declaration order in commands that have both {@code @Option}-annotated methods and {@code @Option}-annotated fields.
+ * The default ({@code true}) is to sort alphabetically.
+ * @return whether options in the synopsis should be shown in alphabetic order.
+ * @since 4.7.0 */
+ boolean sortSynopsis() default true;
+
+ /** Prefix required options with this character in the options list. The default is no marker: the synopsis
+ * indicates which options and parameters are required.
+ * @return the character to show in the options list to mark required options */
+ char requiredOptionMarker() default ' ';
+
+ /** Class that can provide default values dynamically at runtime. An implementation may return default
+ * value obtained from a configuration file like a properties file or some other source.
+ *
+ * Applications may be interested in the {@link PropertiesDefaultProvider} built-in default provider
+ * that allows end users to maintain their own default values for options and positional parameters,
+ * which may override the defaults that are hard-coded in the application.
+ *
+ * @return a Class that can provide default values dynamically at runtime
+ * @since 3.6 */
+ Class extends IDefaultValueProvider> defaultValueProvider() default NoDefaultProvider.class;
+
+ /** Specify {@code true} to show default values in the description column of the options list (except for
+ * boolean options). False by default.
+ * Note that picocli 3.2 allows {@linkplain Option#description() embedding default values} anywhere in the
+ * option or positional parameter description that ignores this setting.
+ * @return whether the default values for options and parameters should be shown in the description column */
+ boolean showDefaultValues() default false;
+
+ /** Specify {@code true} to show a {@code [@...]} entry
+ * in the synopsis and parameter list of the usage help message.
+ * (The entry is not shown if {@linkplain CommandLine#isExpandAtFiles() expanding parameter files} is disabled.)
+ * @since 4.2 */
+ boolean showAtFileInUsageHelp() default false;
+
+ /** Specify {@code true} to show a {@code [--]} "End of options" entry
+ * in the synopsis and option list of the usage help message.
+ * @since 4.3 */
+ boolean showEndOfOptionsDelimiterInUsageHelp() default false;
+
+ /** Set the heading preceding the subcommands list. The default heading is {@code "Commands:%n"} (with a line break at the end).
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the subcommands list
+ * @see Help#commandListHeading(Object...) */
+ String commandListHeading() default "Commands:%n";
+
+ /** Set the heading preceding the footer section.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return the heading preceding the footer section
+ * @see Help#footerHeading(Object...) */
+ String footerHeading() default "";
+
+ /** Optional text to display after the list of options. Each element of the array is rendered on a separate line.
+ * May contain embedded {@linkplain java.util.Formatter format specifiers} like {@code %n} line separators. Literal percent {@code '%'} characters must be escaped with another {@code %}.
+ * @return text to display after the list of options
+ * @see Help#footer(Object...) */
+ String[] footer() default {};
+
+ /**
+ * Set {@code hidden=true} if this command should not be included in the list of commands in the usage help of the parent command.
+ * @return whether this command should be excluded from the usage message
+ * @since 3.0
+ */
+ boolean hidden() default false;
+
+ /** Set the base name of the ResourceBundle to find option and positional parameters descriptions, as well as
+ * usage help message sections and section headings. See {@link Messages} for more details and an example.
+ * @return the base name of the ResourceBundle for usage help strings
+ * @see ArgSpec#messages()
+ * @see UsageMessageSpec#messages()
+ * @see CommandSpec#resourceBundle()
+ * @see CommandLine#setResourceBundle(ResourceBundle)
+ * @since 3.6
+ */
+ String resourceBundle() default "";
+
+ /** Set the {@link UsageMessageSpec#width(int) usage help message width}. The default is 80.
+ * @see UsageMessageSpec#width()
+ * @since 3.7
+ */
+ int usageHelpWidth() default 80;
+
+ /** If {@code true}, picocli will attempt to detect the terminal width and adjust the usage help message accordingly.
+ * End users may enable this by setting system property {@code "picocli.usage.width"} to {@code AUTO},
+ * and may disable this by setting this system property to a {@linkplain UsageMessageSpec#width() numeric value}.
+ * This feature requires Java 7 or greater. The default is {@code false}
+ * @see UsageMessageSpec#autoWidth()
+ * @since 4.0 */
+ boolean usageHelpAutoWidth() default false;
+
+ /** Exit code for successful termination. {@value io.mosn.coder.cli.CommandLine.ExitCode#OK} by default.
+ * @see #execute(String...)
+ * @since 4.0 */
+ int exitCodeOnSuccess() default ExitCode.OK;
+
+ /** Exit code for successful termination after printing usage help on user request. {@value io.mosn.coder.cli.CommandLine.ExitCode#OK} by default.
+ * @see #execute(String...)
+ * @since 4.0 */
+ int exitCodeOnUsageHelp() default ExitCode.OK;
+
+ /** Exit code for successful termination after printing version help on user request. {@value io.mosn.coder.cli.CommandLine.ExitCode#OK} by default.
+ * @see #execute(String...)
+ * @since 4.0 */
+ int exitCodeOnVersionHelp() default ExitCode.OK;
+
+ /** Exit code for command line usage error. {@value io.mosn.coder.cli.CommandLine.ExitCode#USAGE} by default.
+ * @see #execute(String...)
+ * @since 4.0 */
+ int exitCodeOnInvalidInput() default ExitCode.USAGE;
+
+ /** Exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command.
+ * {@value io.mosn.coder.cli.CommandLine.ExitCode#SOFTWARE} by default.
+ * @see #execute(String...)
+ * @since 4.0 */
+ int exitCodeOnExecutionException() default ExitCode.SOFTWARE;
+
+ /** Set the heading preceding the exit codes section, may contain {@code "%n"} line separators. {@code ""} (empty string) by default.
+ * @see Help#exitCodeListHeading(Object...)
+ * @since 4.0 */
+ String exitCodeListHeading() default "";
+
+ /** Set the values to be displayed in the exit codes section as a list of {@code "key:value"} pairs:
+ * keys are exit codes, values are descriptions. Descriptions may contain {@code "%n"} line separators.
+ * For example:
+ *
+ * @Command(exitCodeListHeading = "Exit Codes:%n",
+ * exitCodeList = { " 0:Successful program execution.",
+ * "64:Invalid input: an unknown option or invalid parameter was specified.",
+ * "70:Execution exception: an exception occurred while executing the business logic."})
+ *
+ * @since 4.0 */
+ String[] exitCodeList() default {};
+
+ /** Returns whether subcommands inherit their attributes from this parent command.
+ * @since 4.6 */
+ ScopeType scope() default ScopeType.LOCAL;
+
+ /** Returns the model transformer for this command.
+ * @since 4.6 */
+ Class extends IModelTransformer> modelTransformer() default NoOpModelTransformer.class;
+
+ /** Returns the preprocessor for this command.
+ * @see IParameterPreprocessor
+ * @since 4.6 */
+ Class extends IParameterPreprocessor> preprocessor() default NoOpParameterPreprocessor.class;
+ }
+ /** A {@code Command} may define one or more {@code ArgGroups}: a group of options, positional parameters or a mixture of the two.
+ * Groups can be used to:
+ *
+ * - define mutually exclusive arguments. By default, options and positional parameters
+ * in a group are mutually exclusive. This can be controlled with the {@link #exclusive() exclusive} attribute.
+ * Picocli will throw a {@link MutuallyExclusiveArgsException} if the command line contains multiple arguments that are mutually exclusive.
+ * - define a set of arguments that must co-occur. Set {@link #exclusive() exclusive = false}
+ * to define a group of options and positional parameters that must always be specified together.
+ * Picocli will throw a {@link MissingParameterException MissingParameterException} if not all the options and positional parameters in a co-occurring group are specified together.
+ * - create an option section in the usage help message.
+ * To be shown in the usage help message, a group needs to have a {@link #heading() heading} (which may come from a {@linkplain #headingKey() resource bundle}).
+ * Groups without a heading are only used for validation.
+ * Set {@link #validate() validate = false} for groups whose purpose is only to customize the usage help message.
+ * - define composite repeating argument groups. Groups may contain other groups to create composite groups.
+ *
+ * Groups may be optional ({@code multiplicity = "0..1"}), required ({@code multiplicity = "1"}), or repeating groups ({@code multiplicity = "0..*"} or {@code multiplicity = "1..*"}).
+ * For a group of mutually exclusive arguments, making the group required means that one of the arguments in the group must appear on the command line, or a {@link MissingParameterException MissingParameterException} is thrown.
+ * For a group of co-occurring arguments, all arguments in the group must appear on the command line.
+ *
+ * Groups can be composed for validation purposes:
+ *
+ * - When the parent group is mutually exclusive, only one of the subgroups may be present.
+ * - When the parent group is a co-occurring group, all subgroups must be present.
+ * - When the parent group is required, at least one subgroup must be present.
+ *
+ *
+ * Below is an example of an {@code ArgGroup} defining a set of dependent options that must occur together.
+ * All options are required within the group, while the group itself is optional:
+ *
+ * public class DependentOptions {
+ * @ArgGroup(exclusive = false, multiplicity = "0..1")
+ * Dependent group;
+ *
+ * static class Dependent {
+ * @Option(names = "-a", required = true) int a;
+ * @Option(names = "-b", required = true) int b;
+ * @Option(names = "-c", required = true) int c;
+ * }
+ * }
+ * @see ArgGroupSpec
+ * @since 4.0 */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+ public @interface ArgGroup {
+ /** The heading of this group, used when generating the usage documentation.
+ * When neither a {@link #heading() heading} nor a {@link #headingKey() headingKey} are specified,
+ * this group is used for validation only and does not change the usage help message. */
+ String heading() default "__no_heading__";
+
+ /** ResourceBundle key for this group's usage help message section heading.
+ * When neither a {@link #heading() heading} nor a {@link #headingKey() headingKey} are specified,
+ * this group is used for validation only and does not change the usage help message. */
+ String headingKey() default "__no_heading_key__";
+ /** Determines whether this is a mutually exclusive group; {@code true} by default.
+ * If {@code false}, this is a co-occurring group. Ignored if {@link #validate()} is {@code false}. */
+ boolean exclusive() default true;
+ /** Determines how often this group can be specified on the command line; {@code "0..1"} (optional) by default.
+ * For a group of mutually exclusive arguments, making the group required {@code multiplicity = "1"} means that
+ * one of the arguments in the group must appear on the command line, or a MissingParameterException is thrown.
+ * For a group of co-occurring arguments, making the group required means that all arguments in the group must appear on the command line.
+ * Ignored if {@link #validate()} is {@code false}. */
+ String multiplicity() default "0..1";
+ /** Determines whether picocli should validate the rules of this group ({@code true} by default).
+ * For a mutually exclusive group validation means verifying that no more than one elements of the group is specified on the command line;
+ * for a co-ocurring group validation means verifying that all elements of the group are specified on the command line.
+ * Set {@link #validate() validate = false} for groups whose purpose is only to customize the usage help message.
+ * @see #multiplicity()
+ * @see #heading() */
+ boolean validate() default true;
+ /** Determines the position in the options list in the usage help message at which this group should be shown.
+ * Groups with a lower number are shown before groups with a higher number.
+ * This attribute is only honored for groups that have a {@link #heading() heading} (or a {@link #headingKey() headingKey} with a non-{@code null} resource bundle value).*/
+ int order() default -1;
+ }
+ /**
+ *
+ * When parsing command line arguments and initializing
+ * fields annotated with {@link Option @Option} or {@link Parameters @Parameters},
+ * String values can be converted to any type for which a {@code ITypeConverter} is registered.
+ *
+ * This interface defines the contract for classes that know how to convert a String into some domain object.
+ * Custom converters can be registered with the {@link #registerConverter(Class, ITypeConverter)} method.
+ *
+ * Java 8 lambdas make it easy to register custom type converters:
+ *
+ *
+ * commandLine.registerConverter(java.nio.file.Path.class, s -> java.nio.file.Paths.get(s));
+ * commandLine.registerConverter(java.time.Duration.class, s -> java.time.Duration.parse(s));
+ *
+ * Built-in type converters are pre-registered for the following java 1.5 types:
+ *
+ *
+ * - all primitive types
+ * - all primitive wrapper types: Boolean, Byte, Character, Double, Float, Integer, Long, Short
+ * - any enum
+ * - java.io.File
+ * - java.math.BigDecimal
+ * - java.math.BigInteger
+ * - java.net.InetAddress
+ * - java.net.URI
+ * - java.net.URL
+ * - java.nio.charset.Charset
+ * - java.sql.Time
+ * - java.util.Date
+ * - java.util.UUID
+ * - java.util.regex.Pattern
+ * - StringBuilder
+ * - CharSequence
+ * - String
+ *
+ * @param the type of the object that is the result of the conversion
+ */
+ public interface ITypeConverter {
+ /**
+ * Converts the specified command line argument value to some domain object.
+ * @param value the command line argument String value
+ * @return the resulting domain object
+ * @throws Exception an exception detailing what went wrong during the conversion.
+ * Any exception thrown from this method will be caught and shown to the end user.
+ * An example error message shown to the end user could look something like this:
+ * {@code Invalid value for option '--some-option': cannot convert 'xxxinvalidinput' to SomeType (java.lang.IllegalArgumentException: Invalid format: must be 'x:y:z' but was 'xxxinvalidinput')}
+ * @throws TypeConversionException throw this exception to have more control over the error
+ * message that is shown to the end user when type conversion fails.
+ * An example message shown to the user could look like this:
+ * {@code Invalid value for option '--some-option': Invalid format: must be 'x:y:z' but was 'xxxinvalidinput'}
+ */
+ K convert(String value) throws Exception;
+ }
+
+ /**
+ * Provides version information for a command. Commands may configure a provider with the
+ * {@link Command#versionProvider()} annotation attribute.
+ * @since 2.2 */
+ public interface IVersionProvider {
+ /**
+ * Returns version information for a command.
+ * @return version information (each string in the array is displayed on a separate line)
+ * @throws Exception an exception detailing what went wrong when obtaining version information
+ */
+ String[] getVersion() throws Exception;
+ }
+
+ /**
+ * Converter that can be used to signal to picocli that it should use the default converter.
+ * This can be useful with maps:
+ *
+ * class App {
+ * @Option(names = "-D", converter = {UseDefaultConverter.class, GenericValueConverter.class})
+ * Map<String, GenericValue<?>> values;
+ * }
+ *
+ *
+ * The {@link #convert(String)} method of this class always throws an UnsupportedOperationException.
+ * @since 4.7.0
+ */
+ public static final class UseDefaultConverter implements ITypeConverter