Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tjerkw
Copy link

@tjerkw tjerkw commented Feb 13, 2023

Makes it easier to use a subset of enum values for a certain enum as a Choice ArgType

Makes it easier to use a subset of enum values for a certain enum as a Choice ArgType
Copy link
Member

@ilya-g ilya-g left a 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)

@@ -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(),
Copy link
Member

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
@tjerkw
Copy link
Author

tjerkw commented Feb 15, 2023

I believe this new feature requires tests, a positive and a negative one (e.g. failing on a value not belonging to the subset)

I agree, but dont have the time/resources todo that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants