Skip to content

ANSI control sequences not compatible with docopt parsing  #47

@madsheilskov

Description

@madsheilskov

It would be very neat if docopt::docopt parsing of the "doc"( "help") string would allow for formating using ANSI control sequences. docopt seems to be confused when it matches the square ( [ and ] ) parentheses around the expected "Usage" and "Options" patterns.
This works fine (giving me a boldface and underlined header when I issue ./test.R --help in the command ubuntu command prompt):

`
#!/usr/bin/env Rscript
"
\033[1;4mTest ANSI in R scripts using docopt.\033[0m

Usage:

test.R [--par=PAR]
test.R -h | --help

Options:
--par=PAR The parameter.
-h --help Show help.
" -> doc

suppressWarnings(suppressMessages(require(docopt)))
opt <- docopt(doc)
`

However, now I would like to boldface, say, both "Usage:" and "Options:" like this:
`
#!/usr/bin/env Rscript
"
\033[1;4mTest ANSI in R scripts using docopt.\033[0m
\033[1m
Usage:
\033[0m
test.R [--par=PAR]
test.R -h | --help
\033[1m
Options:
\033[0m
--par=PAR The parameter.
-h --help Show help.
" -> doc

suppressWarnings(suppressMessages(require(docopt)))
opt <- docopt(doc)
`

Then I get the error Unmatched [ (from docopt parsing)

It works fine when only either "Usage:" or "Options:" are embedded in ANSI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions