Skip to content
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

Linewrap usage line? #29

Open
shabbybanks opened this issue Jul 14, 2017 · 4 comments
Open

Linewrap usage line? #29

shabbybanks opened this issue Jul 14, 2017 · 4 comments

Comments

@shabbybanks
Copy link

It is often natural to split up the Usage line based on length when there are multiple options, but this is apparently not possible? The following MWE:

library(docopt)
doc <- "Usage: example.r [-a <ABCEDARIAN>] [-b <BOTHER>] [-t <TOOLONG>] [-q <QUIT_ALREADY>] \
 [-O <OOOPS>]
-a ABCEDARIAN               just an example. [default: abcde]
-b BOTHER                   just an example. [default: bother]
-t TOOLONG                  just an example. [default: 1234]
-q QUIT_ALREADY             just an example. [default: noquit]
-O OOOPS                    just an example. [default: ooops]
"
opt <- docopt(doc,args='-O nofooz')

yields the error

Error:
 usage: example.r [-a <ABCEDARIAN>] [-b <BOTHER>] [-t <TOOLONG>] [-q <QUIT_ALREADY>]

I have tried dropping the backslash, doubling the backslash, adding another Usage: prefix (which causes a different error about multiple Usage: lines) and so on.

sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] docopt_0.4.5   fortunes_1.5-4 drat_0.1.2

loaded via a namespace (and not attached):
[1] magrittr_1.5  tools_3.2.2   stringi_1.1.5 stringr_1.2.0

(see also docopt/docopt#130 , which was of no help).

@shabbybanks
Copy link
Author

My proposed fix would be to optionally allow compatibility with Python (and docopt 'standard' as of 0.6) where Usage: starts the usage stanza and Options: starts the option stanza. Allow the old standard for backwards compatibility, but move towards deprecating it: a mild warning in 2 releases, a stronger warning in 4, and deprecated in 6, or what have you.
See also docopt docs.

@edwindj
Copy link
Member

edwindj commented Jul 18, 2017

Thanks for the suggestion: I will look into it at the end of this week.

Best,

Edwin

@dweemx
Copy link

dweemx commented Dec 20, 2018

Any update on this feature?

Got a work aroung with this:

doc <- gsub(pattern = "\n {2,}", replacement = " ", x = doc)

@benscarlson
Copy link

It would be very nice to be able to wrap long usage strings. This does not appear to be possible as of version 0.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants