default

fun <T : Any> FlagOption<T?>.default(value: T, defaultForHelp: String = value.toString()): FlagOption<T>

Set a default value for an option.

Parameters

defaultForHelp

The help text for this option's default value if the help formatter is configured to show them. Use an empty string to suppress the "default" help text.

fun <EachT : Any, ValueT> NullableOption<EachT, ValueT>.default(value: EachT, defaultForHelp: String = value.toString()): OptionWithValues<EachT, EachT, ValueT>

If the option is not called on the command line (and is not set in an envvar), use value for the option.

This must be applied after all other transforms.

You can customize how the default is shown to the user with defaultForHelp.

Example:

val opt: Pair<Int, Int> by option().int().pair().default(1 to 2)