clikt / com.github.ajalt.clikt.parameters.groups / OptionGroup

OptionGroup

open class OptionGroup : 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:

``` kotlin 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

Name Summary
<init> A group of options that can be shown together in help output, or restricted to be cooccurring.OptionGroup(name:String? = null, help:String? = null)

Properties

Name Summary
groupHelp A help message to display for this group.open val groupHelp:String?
groupName The name of the group, or null if parameters in the group should not be separated from other parameters in the help output.open val groupName:String?

Functions

Name Summary
finalize Called after this command’s argv is parsed and all options are validated to validate the group constraints.open fun finalize(context:Context, invocationsByOption:Map<Option,List<Invocation>>):Unit
postValidate Called after all of a command’s parameters have been finalized to perform validation of the final values.open fun postValidate(context:Context):Unit
registerOption Register an option with this command or group.open fun registerOption(option:GroupableOption):Unit

Extension Functions

Name Summary
cooccurring Make this group a co-occurring group.fun <T :OptionGroup> T.cooccurring():CoOccurringOptionGroup<T, T?>
mutuallyExclusiveOptions Declare a set of two or more mutually exclusive options.fun <T :Any>ParameterHolder.mutuallyExclusiveOptions(option1:OptionDelegate<T?>, option2:OptionDelegate<T?>, vararg options:OptionDelegate<T?>, name:String? = null, help:String? = null):MutuallyExclusiveOptions<T, T?>
option Create a property delegate option.funParameterHolder.option(vararg names:String, help:String= "", metavar:String? = null, hidden:Boolean= false, envvar:String? = null, envvarSplit:Regex? = null, helpTags:Map<String,String> = emptyMap(), completionCandidates:CompletionCandidates? = null):RawOption
provideDelegate operator fun <T :OptionGroup> T.provideDelegate(thisRef:CliktCommand, prop:KProperty<*>):ReadOnlyProperty<CliktCommand, T>