-
Notifications
You must be signed in to change notification settings - Fork 17
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
Embedded space in parameter values #11
Comments
The try.docopt.org doesn't handle shell escaping rules—it just splits the string on whitespace unfortunately. However, the reference implementation does what you expect: """docopt practice script
Usage: foo.R [-i <integers>]
Options:
-i <integers>, --integers=<integers> Integers [default: 1]
"""
from docopt import docopt
print(docopt(__doc__)) Given So this seems to be an error in R port. |
Thanks for reporting! I will look into it tommorow. Best regards, Edwin |
@jennybc: I have added a test with your example and it seems to works with the latest github version. The problem was that Question: I would like to change the Best, Edwin |
Thanks @edwindj for the fix! I would be fine if the CRAN update requires R >= 3.2, so go right ahead as far as I'm concerned. |
Hi @edwindj, I'm not seeing this as fixed (or not understanding the intention of quoted_args) My script, qtest, is as follows:
I would expect that opt$s would be "hello world" when called as below, but, alas it is not.
Can you advise? Note the script shows that commandArgs is seeing "hello world" as a single value. I am using docopt_0.4.4 on R version 3.2.1 (2015-06-18) |
@malcook Thanks for reporting: it is a bug, that only happens when one argument is given: . I will look into it tomorrow Best, Edwin |
@malcook: should be fixed... |
It still does not work here, even after installing the latest updates. Try this really minimal example:
It will work without spaces, but not with spaces, e.g. Also note that passing a star does not work (which is useful to mimic typical bash usage to execute something on a whole directory): Great work though, and please keep up this great project! |
This seems to be still broken. I'm working around it for now by embedding _ where I'd like a space, then using gsub inside R to clean it up. Not ideal. Any chance this could get another look? |
I will be working on it the end of this week |
Any luck on this? Thanks |
I'm also curious about the status of this. Just taught a class on docopt to 40+ people in my agency yesterday, and this question generated a lot of interest when it came up. |
I may have solved this a long time ago, but did not upload it yet to CRAN.
If fixed, I will uploaded it to CRAN asap, so it will be official. Best, |
Thanks for the response, Edwin. I installed the GitHub version and ran a minimal example similar to the one cysouw used above:
I get the following output on my system: GIGte_programmaticR$ ./test.R Jo locale: attached base packages: other attached packages: loaded via a namespace (and not attached): GIGte_programmaticR$ ./test.R "Jo Williams" Am I missing something? Thank you for your help. |
Thanks for your detailed report! I have made some changes: |
YES! works here now R version 3.2.2 (2015-08-14) locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
The minimal example I posted is now working on my system as well - thank you! |
Any idea on when this will make it to CRAN? |
Thx for reminding :-), I will send it to CRAN within two days. |
on its way to CRAN (will close it when accepted) |
Thanks for providing this docopt implementation for R!
I was pleased to see it can handle quoted arguments. I'm a little surprised that the example below -- where I have spaces embedded in a parameter value -- doesn't work.
Homework & context:
docopt
R package matches the behaviour I get here (http://try.docopt.org),so your package definitely matches the reference implementation in this caseupdate: I did not actually compare against the reference, so will just limit my comment to doctopt.org. But even lots of unix command line utilities allow for embedded space, possibly escaped, in parameter values. So why not docopt?Sample R script
foo.R
:Basically I want to pass an R expression that will generate an atomic vector of integers. Some successful usage and some less successful:
Obviously I can just avoid using spaces! But it got me wondering about the general question. Any thoughts?
BTW you might find it interesting that something special and bad happens if you try to use an option with short form
-g
: a question I asked on stackoverflow.The text was updated successfully, but these errors were encountered: