-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ArgType.Choice for Enums to limit list of values #96
base: master
Are you sure you want to change the base?
Conversation
Makes it easier to use a subset of enum values for a certain enum as a Choice ArgType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this new feature requires tests, a positive and a negative one (e.g. failing on a value not belonging to the subset)
core/commonMain/src/ArgType.kt
Outdated
@@ -75,11 +75,12 @@ abstract class ArgType<T : Any>(val hasParameter: kotlin.Boolean) { | |||
* Helper for arguments that have limited set of possible values represented as enumeration constants. | |||
*/ | |||
inline fun <reified T : Enum<T>> Choice( | |||
values: List<T> = enumValues<T>().toList(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other similar overload such list is called choices
This makes it easier to use the commands, cause it will print the help text when you set printHelpOnEmptyArgs = true
Allow passing printHelpOnEmptyArgs to ArgParser
Use choices, update toVariant
I agree, but dont have the time/resources todo that now. |
Makes it easier to use a subset of enum values for a certain enum as a Choice ArgType