optionalValueLazy

fun <ValueT : Any> NullableOption<ValueT, ValueT>.optionalValueLazy(acceptsUnattachedValue: Boolean = true, default: () -> ValueT): NullableOption<ValueT, ValueT>

Allow this option to be specified with or without an explicit value.

If the option is specified on the command line without a value, default will be called and its return value can be used.

To avoid ambiguity when combined with arguments, you can set acceptsUnattachedValue to false to require that the option's value be specified like --foo=bar rather than --foo bar.

You can use optionalValue if you don't need to reference other parameters.

Example

val log by option().optionalValueLazy{"verbose"}.default("none")

> ./tool --log=debug
log level == debug

> ./tool --log
log level == verbose

> ./tool
log level == none