flag

fun RawOption.flag(vararg secondaryNames: String, default: Boolean = false, defaultForHelp: String = ""): FlagOption<Boolean>

Turn an option into a boolean flag.

Parameters

secondaryNames

additional names for that option that cause the option value to be false. It's good practice to provide secondary names so that users can disable an option that was previously enabled.

default

the value for this property if the option is not given on the command line.

defaultForHelp

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

Example:

val flag by option(help = "flag option").flag("--no-flag", default = true, defaultForHelp = "enable")
// Options:
// --flag / --no-flag flag option (default: enable)