Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

docopt.R

Command-line interface description language for R (http:docopt.org)

Subscribe to updates I use docopt.R


Statistics on docopt.R

Number of watchers on Github 92
Number of open issues 14
Average time to close an issue 2 months
Main language R
Average time to merge a PR 6 days
Open pull requests 1+
Closed pull requests 1+
Last commit about 2 years ago
Repo Created almost 6 years ago
Repo Last Updated over 1 year ago
Size 174 KB
Organization / Authordocopt
Contributors4
Page Updated
Do you use docopt.R? Leave a review!
View open issues (14)
View docopt.R activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating docopt.R for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

version downloads Build Status

docopt

docopt helps you to:

  • define an interface for your command-line app, and
  • automatically generate a parser for it.

For more information see docopt.org

R package docopt is an implementation of docopt in the R language. See my presentation on the useR! 2014 for more details.

Install

The latest version of docopt can be installed using:

library(devtools)  # make sure to have devtools 1.4!
install_github("docopt/docopt.R")

It is tested against the tests defined for the reference implementation. It passes most tests. It currently fails tests that

  • count arguments: my_prog.R -v -v should return list(v=2)

The tests can be run using devtools test() and can be found in inst/tests

Usage

docopt uses the description of the command-line interface to parse command line arguments.

'usage: my_prog.R [-a -r -m <msg>]

options:
 -a        Add
 -r        Remote
 -m <msg>  Message' -> doc

# load the docopt library
library(docopt)
# retrieve the command-line arguments
opts <- docopt(doc)
# what are the options? Note that stripped versions of the parameters are added to the returned list
str(opts)  
## List of 3
##  $ -a: logi FALSE
##  $ -r: logi FALSE
##  $ -m: chr "<msg>"
##  $ a: logi FALSE
##  $ r: logi FALSE
##  $ m: chr "<msg>"

# or set them manually
opts <- docopt(doc, "-m Hello")
str(opts)
## List of 3
##  $ -a: logi FALSE
##  $ -r: logi FALSE
##  $ -m: chr "Hello"
##  $ a: logi FALSE
##  $ r: logi FALSE
##  $ m: chr "Hello"

Note

There is an issue with using -g and -gui with docopt.R as reported on Stackoverflow. Rscript filters on -g and -gui before docopt.R can access them.

docopt.R open issues Ask a question     (View All Issues)
  • about 3 years Possibility to source a script and passing arguments to it
  • about 3 years Required options resulting in error
  • about 3 years Expose/implement options_first
  • about 3 years adding [options] breaks required combinations
  • about 3 years missing options are either NULL or list() depending on "Options:" section
  • over 3 years Mishandling of spaces in arguments' values
  • over 3 years Distributing docopt scripts
  • over 3 years Using stars as argument
  • over 3 years Print full --help message on error when no arguments are passed?
docopt.R open pull requests (View All Pulls)
  • Remove to-be-obsolete '-g' and '--gui' warning
docopt.R list of languages used
Other projects in R