Open Question: Why is greedy not part of the command context? #373
bergerkiller
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm starting to run into a situation where I would like to use @greedy in custom argument parsers. I find that greedy is instead deeply rooted in the standard parsers, and you need to pass some properties to the ArgumentParser object you supply.
In other words, to simply accept an argument with spaces in it, I need to change the argument parser itself, how it is registered, and I'm not sure if what I want even works properly.
Why isn't there a
isGreedy()
property on the CommandContext itself? Then parsers can check if its greedy and if so, consume the entire queue as part of parsing, and otherwise, consume only one element. This would greatly simplify this api.My current use case involves double values with units. For example, users can specify:
But there's no reason why they shouldn't be able to:
I see no real reason why accepting input with spaces in them should be so strict. Even nicer would be @greedy / setGreedy() squashing the inputs into one separated by spaces, so argument parsers don't even have to take greedy into account.
P.s. I might have trouble with this because of #139
Beta Was this translation helpful? Give feedback.
All reactions