Replies: 1 comment 1 reply
-
No, because it leads to ambiguities in parsing. Let's say we parse 4 tokens then find we need one more for the next arg. We'd need to implement backtracking to the reset the parse state, consume 3, then try again. Backtracking would add a ton of complexity and be slower. It would get worse with multiple ranged arguments or optional arguments. And impossible with subcommands. That's why you can only have one greedy argument, and optional arguments always fill left to right. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
Is there a way to allow a range of arguments in click using
nargs
, such exactly between 2 and 4 arguments? Something like the following, for example, in atest.py
file:Which would then allow:
But disallow:
I'm expecting this to work similar to
nargs=-1
, where it swallows everything after it.Thank you kindly for the help!
Beta Was this translation helpful? Give feedback.
All reactions