Open delarosatrevin opened 6 years ago
The -
characters are processed before they get to docopt
. This is more of a shell limitation than a docopt
one.
Depending on your usecase you probably work around the issue by quoting negative numbers, eg:
$ calculator add 3 '-2'
Hi, thanks for your answer.
I think this is not a shell 'issue', since all arguments are passed in the sys.argv list (containing '-' or not). I know that quoting in literals could be a workaround, but then the programs invocation is a bit unnatural. Another workaround in docopt arguments and value parsing could be to check the next character after the '-', if it is a digit, then is very likely to be a number. I have tested that in my fork of the cpp port.
Yes you're right; I was confusing myself.
Have you seen this solution ? I don't know if it's relevant to your use case, but it was a good fit for mine.
Thanks @galactics! I made a small change in my docopt-cpp fork and I'm happy with it so far. But I haven't decided yet if I will go fully with docopt anyway. I'm writing a library and so far only a few example programs in C++.
Hi, first of all, many thanks for developing this library.
I'm starting to write a library for scientific image processing (Electron Microscopy images) and I was considering to use docopt for command line parsing. In the past I have written my own home-made tools, of course much more limited.
I have started playing with docopt and I have found that negatives values are not properly parsed. Maybe it is getting wrong the regex matching since the negative numbers start with a dash as the optional arguments. I tried the simple example of the calculator and it is not working as expected. I think this issue is important for any scientific application that needs to deal with negatives values.