ajalt / clikt

Multiplatform command line interface parsing for Kotlin
https://ajalt.github.io/clikt/
Apache License 2.0
2.51k stars 121 forks source link

Mutually exclusive options in OptionGroup #511

Closed daring2 closed 4 months ago

daring2 commented 4 months ago

Hello,

Is it possible to use mutually exclusive options (mutuallyExclusiveOptions) inside OptionGroup class?

Example:

class TestOptions: OptionGroup() {
    val test by mutuallyExclusiveOptions(
        option("--p1"),
        option("--p2"),
    )
}

In this example I get the following compiler error:

Property delegate must have a 'getValue(TestOptions, KProperty<*>)' method. None of the following functions is suitable: 
public open fun getValue(thisRef: CliktCommand, property: KProperty<*>): String? defined in com.github.ajalt.clikt.parameters.groups.MutuallyExclusiveOptions
ajalt commented 4 months ago

This has been asked before in #393. Nested groups are not supported.