option

fun ParameterHolder.option(vararg names: String, help: String = "", metavar: String? = null, hidden: Boolean = false, envvar: String? = null, helpTags: Map<String, String> = emptyMap(), completionCandidates: CompletionCandidates? = null, valueSourceKey: String? = null, eager: Boolean = false): RawOption

Create a property delegate option.

By default, the property will return null if the option does not appear on the command line. If the option is invoked multiple times, the value from the last invocation will be used The option can be modified with functions like int, pair, and multiple.

Parameters

names

The names that can be used to invoke this option. They must start with a punctuation character. If not given, a name is inferred from the property name.

help

The description of this option, usually a single line.

metavar

A name representing the values for this option that can be displayed to the user. Automatically inferred from the type.

hidden

Hide this option from help outputs.

envvar

The environment variable that will be used for the value if one is not given on the command line.

helpTags

Extra information about this option to pass to the help formatter

completionCandidates

The values to use for tab completion.

valueSourceKey

The key to use when reading this option from a ValueSource.

eager

If true, this option will be parsed before other options. This is useful for options like --version that will stop parsing immediately by throwing a PrintHelpMessage or ProgramResult exception in their validate callback. If your option is a flag, you can use eagerOption instead.