-
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
Mishandling of spaces in arguments' values #19
Comments
Same issue here. Might be related, see Edit: Actually, issue on my code is with use of the |
Two years have passed, and the OPs script above seems to work for me. I have other space-related problems but this issue might warrant closing. |
agree with @vforget. Here's a reprex: #!/usr/bin/env Rscript
'style files.
Usage:
style_files [--arg=<arg1>] <files>...
Options:
--arg=<arg1> Package where the style guide is stored [default: Arg1].
' -> doc
arguments <- docopt::docopt(doc)
print(arguments)
saveRDS(arguments, 'argument.rds') No problem here: (base) lorenz precommit $ ~/short-term/docopt-error --arg='ab' f1 f2 √ 22:57:33
List of 4
$ --arg : chr "ab"
$ <files>: chr [1:2] "f1" "f2"
$ arg : chr "ab"
$ files : chr [1:2] "f1" "f2"
NULL But this does not work: (base) lorenz precommit $ ~/short-term/docopt-error --arg='a b' f1 f2 ×1 22:56:34
List of 4
$ --arg : chr "Arg1"
$ <files>: chr [1:3] "--arg=a b" "f1" "f2"
$ arg : chr "Arg1"
$ files : chr [1:3] "--arg=a b" "f1" "f2"
NULL
|
Thanks for reporting!
(without the assignment sign), does work. |
Jup, true. Thanks @edwindj, it would be awesome to see this fixed. If it motivates you: this edge case will be used in {precommit} to allow people to select the style guide for formatting, as described in lorenzwalthert/precommit#178 (comment). |
I seem to have fixed the issue. |
Perfect, I'll take a look. |
Unfortunately not -.-, I filed #40 to describe exactly what does not work as expected. |
Hi guys,
I cannot seem to have doctopt to properly handle argument values that contain spaces. Here is a reproducible example:
If I call this script with
./test.R foo -B bar
, everything is fine. But the following are considered errors:./test.R foo -B "bar baz"
./test.R foo -B 'bar bar'
./test.R foo -b bar baz
(this last one to be expected)Best,
Aurélien
The text was updated successfully, but these errors were encountered: