Skip to content

Linewrap usage line? #29

Open
Open
@shabbybanks

Description

@shabbybanks

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).

Activity

shabbybanks

shabbybanks commented on Jul 14, 2017

@shabbybanks
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

edwindj commented on Jul 18, 2017

@edwindj
Member

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

Best,

Edwin

dweemx

dweemx commented on Dec 20, 2018

@dweemx

Any update on this feature?

Got a work aroung with this:

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

benscarlson commented on Jan 26, 2024

@benscarlson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @edwindj@benscarlson@dweemx@shabbybanks

        Issue actions

          Linewrap usage line? · Issue #29 · docopt/docopt.R