Hello,

I'm using the R package argparse to parse command line arguments.

For readability, I'd like to add line breaks in the "description" of the
script and in the help of the arguments. However, I can't do it... Let's
see an example. Given this script:

    #!/usr/bin/env Rscript

    require(argparse)

    docstring<- "Description\nDone"

    parser<- ArgumentParser(description= docstring)
    args<- parser$parse_args()

When executed with *-h* it should print:

    Description
    Done

However, I'm getting the error:

    Error in rjson::fromJSON(output) : unexpected character 'F'
    Calls: <Anonymous> -> <Anonymous> -> <Anonymous>
    Execution halted

Variation of docstring like *paste("Description", "Done", sep= '\n')* are
equally unsuccessful.

As well as passing RawTextHelpFormatter like:
parser<- ArgumentParser(description= docstring, RawTextHelpFormatter= TRUE)

Any idea how to put line breaks in argparse?

Many thanks!

NB: Cross posted on StackOverflow http://stackoverflow.com/posts/27150625/

Dario

    sessionInfo()
    R version 3.0.1 (2013-05-16)
    Platform: x86_64-apple-darwin10.8.0 (64-bit)

    locale:
    [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

    other attached packages:
    [1] argparse_1.0.1 proto_0.3-10

    loaded via a namespace (and not attached):
    [1] findpython_1.0.1 getopt_1.20.0    rjson_0.2.13

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to