Closed dodie closed 5 years ago
The @AllowedEnumValues
should do what you want, simply add this to the relevant option declaring the class of your enum e.g.
public class MyCommand {
...
@Option(name = {"--my-enum"}, description = "This is MyEnum. Possible values: EXAMPLE_A, EXAMPLE_B")
@AllowedEnumValues(MyEnum.class)
MyEnum myEnum;
...
}
See http://rvesse.github.io/airline/guide/annotations/allowed-enum-values.html for the docs
This is a relatively new feature that was added as of the 2.7.0 release
Just what I needed, thanks, @rvesse !
Hi!
I have a command, with an enum as an option:
Is it possible to automatically include all possible values of the
enum
to the description instead of hard-coding them in the description?I've tried to include them based on MyEnum.values(), but annotations can only consume compile time constants. Is there an airline annotation (or plans to have such feature) that makes this possible?
Cheers and thank you, David