OptionGroup

open class OptionGroup(name: String? = null, help: String? = null) : ParameterGroup, ParameterHolder

A group of options that can be shown together in help output, or restricted to be cooccurring.

Declare a subclass with option delegate properties, then use an instance of your subclass is a delegate property in your command with provideDelegate.

Example:

class UserOptions : OptionGroup(name = "User Options", help = "Options controlling the user") {
val name by option()
val age by option().int()
}

class Tool : CliktCommand() {
val userOptions by UserOptions()
}

Constructors

Link copied to clipboard
fun OptionGroup(name: String? = null, help: String? = null)

Functions

Link copied to clipboard
open override fun finalize(context: Context, invocationsByOption: Map<Option, List<OptionParser.Invocation>>)

Called after this command's argv is parsed and all options are validated to validate the group constraints.

Link copied to clipboard
Link copied to clipboard
open override fun postValidate(context: Context)

Called after all of a command's parameters have been finalized to perform validation of the final values.

Link copied to clipboard
open override fun registerOption(option: GroupableOption)

Register an option with this command or group.

Properties

Link copied to clipboard
open override val groupHelp: String?

A help message to display for this group.

Link copied to clipboard
open override val groupName: String?

The name of the group, or null if parameters in the group should not be separated from other parameters in the help output.

Extensions

Link copied to clipboard
fun <T : Any> ParameterHolder.mutuallyExclusiveOptions(option1: OptionDelegate<out T?>, option2: OptionDelegate<out T?>, vararg options: OptionDelegate<out T?>, name: String? = null, help: String? = null): MutuallyExclusiveOptions<T, T?>

Declare a set of two or more mutually exclusive options.

Link copied to clipboard
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): RawOption

Create a property delegate option.