Replies: 1 comment
-
|
Actually, I just thought of a hack solution not using click's API: It's ugly, but it works. Still might be nice to have a way to do it within click. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, all. I've used click for a fair number of scripts, but have run into an interface requirement that I can't seem to figure out how to accomplish with click's API.
Specifically, I've got a one-function script which will take no options [1], only required and optional arguments. The first argument is a floating point number, which can be positive or negative. You can see where this is going; click treats the leading dash on a negative number as introducing an option, which then raises a "no such option" error.
I can forcibly end parsing of options by invoking it as
script -- -13.87 arg2 arg3..., but it's kind of ugly, considering there are no options to parse, and involves remembering to do it on every invocation.I've tried various things without success. I'm using a single
@click.command(...)-decorated function in the script, and have tried explicitly passingparams=containing only Argument objects, with and withoutis_eagerbeing True - I'd hoped that making Argument processing eager would consume the values before it got to option processing, but no luck.Approaches I've looked for, but may have missed:
Simplest version of the script:
Running it with a positive value is fine, but a negative one fails:
I would appreciate any info/suggestions on how this can be accomplished with click's existing API.
Thanks,
Charles
[1] I'd be happy if the automatic
--helpoption could be supported, but losing it is fine if it makes the above work.Beta Was this translation helpful? Give feedback.
All reactions