You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The groupChoice feature allow users to define multiple groups and use an option to select one from these. The doc said that:
Options for groups other than the selected one are ignored
I am wondering if it's possible to emit an error other than just ignoring the option from other group. And then it will be less error prone.
For example:
sealedclassLoadConfig(name:String): OptionGroup(name)
classFromDisk : LoadConfig("Options for loading from disk") {
val path by option().file().required()
val followSymlinks by option().flag()
}
classFromNetwork: LoadConfig("Options for loading from network") {
val url by option().required()
val username by option().prompt()
val password by option().prompt(hideInput =true)
}
classTool : CliktCommand(help = "An example of a custom help formatter that uses ansi colors") {
val load by option().groupChoice(
"disk" to FromDisk(),
"network" to FromNetwork()
)
overridefunrun() {
when(val it = load) {
isFromDisk-> echo("Loading from disk: ${it.path}")
isFromNetwork-> echo("Loading from network: ${it.url}")
null-> echo("Not loading")
}
}
}
Usage:
$ ./tool --load=disk --path=./config --follow-symlinks --username=admin
Error: No option "--username" when "--load=disk"
The text was updated successfully, but these errors were encountered:
The groupChoice feature allow users to define multiple groups and use an option to select one from these. The doc said that:
I am wondering if it's possible to emit an error other than just ignoring the option from other group. And then it will be less error prone.
For example:
Usage:
The text was updated successfully, but these errors were encountered: