docopt

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

https://github.com/docopt/docopt.r

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

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

Basic Info
  • Host: GitHub
  • Owner: docopt
  • License: other
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 243 KB
Statistics
  • Stars: 216
  • Watchers: 14
  • Forks: 17
  • Open Issues: 19
  • Releases: 0
Created over 12 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License

README.md

version downloads R build status AppVeyor Build Status status

docopt

docopt helps you to:

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

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

For more information see docopt.org

To try docopt in your browser visit try.docopt.org

Installation

The easiest way to get docopt is to install from CRAN:

R install.packages("docopt") library(docopt)

Development version

The latest version of docopt can be installed from GitHub using devtools:

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

Testing

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 "tests" directory.

R library(devtools) devtools::test()

Usage

docopt uses the description of the command-line interface (i.e. help message docstring) to parse command-line arguments.

```R 'Naval Fate.

Usage: navalfate.R ship new ... navalfate.R ship move [--speed=] navalfate.R ship shoot navalfate.R mine (set|remove) [--moored | --drifting] navalfate.R (-h | --help) navalfate.R --version

Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine.

' -> doc

library(docopt) arguments <- docopt(doc, version = 'Naval Fate 2.0') print(arguments) ```

The option parser is generated based on the docstring above that is passed to docopt function. docopt parses the usage pattern ("Usage: ...") and option descriptions (lines starting with dash "-") and ensures that the program invocation matches the usage pattern; it parses options, arguments and commands based on that. The basic idea is that a good help message has all necessary information in it to make a parser.

To execute your command-line application you need to provide path to command-line executable file (i.e. naval_fate.R in our case) and provide relevant command-line arguments/options/commands.

For example

  • To print command-line application help message:

``` $ Rscript path/to/naval_fate.R --help Naval Fate.

Usage: navalfate.R ship new ... navalfate.R ship move [--speed=] navalfate.R ship shoot navalfate.R mine (set|remove) [--moored | --drifting] navalfate.R (-h | --help) navalfate.R --version

Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. ```

  • To print command-line application version information:

$ Rscript path/to/naval_fate.R --version Naval Fate 2.0

  • docopt function returns a list of command-line parameters and their corresponding values that can be accessed via $ within your command-line application.

$ Rscript path/to/naval_fate.R ship Guardian move 10 50 --speed=20 List of 23 $ --help : logi FALSE $ --version : logi FALSE $ --speed : chr "20" $ --moored : logi FALSE $ --drifting: logi FALSE $ ship : logi TRUE $ new : logi FALSE $ <name> : chr "Guardian" $ move : logi TRUE $ <x> : chr "10" $ <y> : chr "50" $ shoot : logi FALSE $ mine : logi FALSE $ set : logi FALSE $ remove : logi FALSE $ help : logi FALSE $ version : logi FALSE $ speed : chr "20" $ moored : logi FALSE $ drifting : logi FALSE $ name : chr "Guardian" $ x : chr "10" $ y : chr "50"

  • In case if provided command-line parameters are inconsistent with the "Usage: ..." pattern the error message will be printed along with usage pattern examples.

``` $ Rscript path/to/navalfate.R ship mine Error: usage: navalfate.R ship new ...

usage: naval_fate.R ship move [--speed=]

usage: naval_fate.R ship shoot

usage: naval_fate.R mine (set|remove) [--moored | --drifting]

usage: naval_fate.R (-h | --help)

usage: naval_fate.R --version Execution halted ```

Owner

  • Name: docopt
  • Login: docopt
  • Kind: organization
  • Location: Your terminal

GitHub Events

Total
  • Commit comment event: 3
  • Issues event: 1
  • Watch event: 4
  • Issue comment event: 3
  • Push event: 5
Last Year
  • Commit comment event: 3
  • Issues event: 1
  • Watch event: 4
  • Issue comment event: 3
  • Push event: 5

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 174
  • Total Committers: 7
  • Avg Commits per committer: 24.857
  • Development Distribution Score (DDS): 0.098
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Edwin de Jonge e****e@g****m 157
Dirk Eddelbuettel e****d@d****g 6
Andrey Smelter a****r@g****m 6
Bjarte Johansen b****n@g****m 2
trevorld t****s@g****m 1
Peter Schulam p****m@g****m 1
Steven Pav s****n@c****o 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 36
  • Total pull requests: 13
  • Average time to close issues: 9 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 29
  • Total pull request authors: 8
  • Average comments per issue: 3.14
  • Average comments per pull request: 1.31
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • eddelbuettel (3)
  • mmuurr (3)
  • cysouw (2)
  • lorenzwalthert (2)
  • antonkulaga (2)
  • zkamvar (1)
  • eyzhao (1)
  • yasuiniko (1)
  • madsheilskov (1)
  • dselivanov (1)
  • aniketschneider (1)
  • cboettig (1)
  • rgrannell1 (1)
  • lf-araujo (1)
  • tanho63 (1)
Pull Request Authors
  • eddelbuettel (6)
  • trevorld (1)
  • pschulam (1)
  • lorenzwalthert (1)
  • rgrannell1 (1)
  • andreysmelter (1)
  • shabbychef (1)
  • ljos (1)
Top Labels
Issue Labels
enhancement (1) bug (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 8,814 last-month
  • Total docker downloads: 62,538,975
  • Total dependent packages: 10
    (may contain duplicates)
  • Total dependent repositories: 64
    (may contain duplicates)
  • Total versions: 15
  • Total maintainers: 1
cran.r-project.org: docopt

Command-Line Interface Specification Language

  • Versions: 10
  • Dependent Packages: 8
  • Dependent Repositories: 57
  • Downloads: 8,814 Last month
  • Docker Downloads: 62,538,975
Rankings
Stargazers count: 2.1%
Dependent repos count: 3.2%
Forks count: 3.8%
Downloads: 5.5%
Dependent packages count: 6.1%
Average: 6.4%
Docker downloads count: 17.7%
Maintainers (1)
Last synced: 11 months ago
conda-forge.org: r-docopt
  • Versions: 5
  • Dependent Packages: 2
  • Dependent Repositories: 7
Rankings
Dependent repos count: 12.9%
Dependent packages count: 19.6%
Average: 23.9%
Stargazers count: 26.4%
Forks count: 36.7%
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • methods * imports
  • testthat * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite