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

Consider specifying limits on counted #483

Closed
JakeWharton opened this issue Feb 7, 2024 · 0 comments · Fixed by #484
Closed

Consider specifying limits on counted #483

JakeWharton opened this issue Feb 7, 2024 · 0 comments · Fixed by #484

Comments

@JakeWharton
Copy link

JakeWharton commented Feb 7, 2024

Sometimes I check that a counted flag isn't too high and I either clamp it or I produce an error. It's not too hard to do myself, of course, but I figured I'd propose it for inclusion in counted directly.

Maybe

counted(limit: Int = Int.MAX_VALUE, error: Boolean = false)

This would allow

val verbosity by option("-v").counted(limit = 3)

or

val rotations by options("-r").counted(limit = 2, error = true)

but also allows this somewhat useless form

val inputCount by options("-i").counted(error = true) // never errors

Like I said, I don't need this, but I've written counted validation at least three times now so I figured it was worth proposing for inclusion.

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 a pull request may close this issue.

1 participant