Can I do a choice-based option that allows for a d...
# clikt
j
Can I do a choice-based option that allows for a default choice value (if none provided) but is still nullable if the flat is omitted?
Copy code
./cli          --> null
./cli --foo    --> default (a)
./cli --foo=a  --> a
./cli --foo=b  --> b
a
Not in the current release, but the 4.0 branch has support for options with variadic values. https://github.com/ajalt/clikt/blob/4.0/docs/options.md#options-with-an-optional-value In that branch, you can make an option like your example with
option().choice("a", "b").optionalValue("a")
You can try it with a snapshot build if you want. https://github.com/ajalt/clikt#snapshots
j
Perfect. Thanks!
s
Coming here from https://github.com/ajalt/clikt/issues/381, is there any ETA for version 4 yet? At least I don't see any open issues with that milestone 😁