Jim
03/14/2023, 3:06 AMclass Pet(kind: String) : OptionGroup(kind) {
val name by option()
class Cat : Pet("cat") {
val declawed by option().flag
}
class Dog : Pet("dog") {
val floppyEars by option().flag()
}
Gives an error like: Duplicate option name --name
- this is trivial of course, but doesn't allow the full expression of an hierarchical data structure for larger program configs--cat-name
Phil Richardson
03/14/2023, 10:24 AM--name catName
, which will be consumed by both Pets assigned to your command.
That or I suspect your Cat/Dog example may not do your scenario justice to explain that it may / may not be OK that name being the same value would be valid and mandatory (though I can't think of a sane short example to test that theory).Jim
03/14/2023, 3:53 PMsealed class LoadConfig(name: String): OptionGroup(name) {
val outName by option()
}
class FromDisk : LoadConfig("Options for loading from disk") {
val path by option().required()
val followSymlinks by option().flag()
}
class FromNetwork: LoadConfig("Options for loading from network") {
val url by option().required()
val username by option().prompt()
val password by option().prompt(hideInput = true)
}
Here's a much better and relatable example
Duplicate option name --out-name
The out name is what the file should be saved as and makes sense if it comes from network and from disk, and the load
option is presumably how the runtime decides which case to usePhil Richardson
03/14/2023, 5:43 PMOptions for the groups other than the selected one are ignored, ...In this case, correct use of groupChoice/Select don't quite completely ignore the non-selected, as the requirement for unique option names is enforced even against non-selected