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

ANSI control sequences not compatible with docopt parsing #47

Open
madsheilskov opened this issue Jun 29, 2021 · 0 comments
Open

ANSI control sequences not compatible with docopt parsing #47

madsheilskov opened this issue Jun 29, 2021 · 0 comments

Comments

@madsheilskov
Copy link

madsheilskov commented Jun 29, 2021

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.

@madsheilskov madsheilskov changed the title ANSCI control sequences not compatible with docopt parsing ANSI control sequences not compatible with docopt parsing Jun 29, 2021
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

1 participant