R Observatory
Search
install.packages("optparse")
CRAN 30-day downloads, method
18,930−1.8% down on the 30 days before, the worse direction
Dependent packages, method
510 more suggest it
Test coverage, method
98%of lines run by tests

A command line parser inspired by Python's 'optparse' library to be used with Rscript to write "#!" shebang scripts that accept short and long flag/options.

Maintainer
Trevor L. Davis
Licence
GPL (>= 2)
Latest release
17 Apr 2026
First release
3 Nov 2009

Compare with another package

More details
Releases
22
Needs compilation
No
Needs R
>= 3.6.0
Config/testthat/edition
3
RoxygenNote
7.3.3
Subjects (1) Method, Subjects
Cite

Package

Run in R for the authors' preferred citation:

citation("optparse")
APA
Davis, T. L., Python Software Foundation, Choi, G. J., Day, A., FitzJohn, R., Humburg, P., Lianoglou, S., Müller, K., & Nikelski, J. (2026). optparse: Command Line Option Parser (Version 1.8.2) [Computer software]. https://doi.org/10.32614/CRAN.package.optparse
About

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA
Balamuta, J. J. (2026). R Observatory: Metrics for optparse version 1.8.2 [Data set]. HJJB, LLC. Data release v2026-10-28. https://doi.org/10.5281/zenodo.21843040
About

From data release v2026-10-28, which the citation names so these numbers can be found later.

All 13 check platforms pass.

  • r-devel-linux-x86_64-debian-clang

    The unreleased R on Linux, x86_64, debian-clang

    OK

    Version checked
    1.8.2
    Time taken
    44 s
  • r-devel-linux-x86_64-debian-gcc

    The unreleased R on Linux, x86_64, debian-gcc

    OK

    Version checked
    1.8.2
    Time taken
    34 s
  • r-devel-linux-x86_64-fedora-clang

    The unreleased R on Linux, x86_64, fedora-clang

    OK

    Version checked
    1.8.2
    Time taken
    42 s
  • r-devel-linux-x86_64-fedora-gcc

    The unreleased R on Linux, x86_64, fedora-gcc

    OK

    Version checked
    1.8.2
    Time taken
    35 s
  • r-devel-windows-x86_64

    The unreleased R on Windows, x86_64

    OK

    Version checked
    1.8.2
    Options
    --no-vignettes
    Time taken
    79 s
  • r-oldrel-macos-arm64

    The previous release of R on macOS, arm64

    OK

    Version checked
    1.8.2
    Time taken
    17 s
  • r-oldrel-macos-x86_64

    The previous release of R on macOS, x86_64

    OK

    Version checked
    1.8.2
    Time taken
    96 s
  • r-oldrel-windows-x86_64

    The previous release of R on Windows, x86_64

    OK

    Version checked
    1.8.2
    Options
    --no-vignettes
    Time taken
    62 s
  • r-patched-linux-x86_64

    The patched release of R on Linux, x86_64

    OK

    Version checked
    1.8.2
    Time taken
    38 s
  • r-release-linux-x86_64

    The current release of R on Linux, x86_64

    OK

    Version checked
    1.8.2
    Time taken
    38 s
  • r-release-macos-arm64

    The current release of R on macOS, arm64

    OK

    Version checked
    1.8.2
    Time taken
    18 s
  • r-release-macos-x86_64

    The current release of R on macOS, x86_64

    OK

    Version checked
    1.8.2
    Time taken
    61 s
  • r-release-windows-x86_64

    The current release of R on Windows, x86_64

    OK

    Version checked
    1.8.2
    Options
    --no-vignettes
    Time taken
    56 s
  • 13 OK

Over time

No change since 5 Aug 2026

As a list (3)
ChangedWorst statusOKNotesWarningsErrors
5 Aug 2026OK13000
1 Aug 2026Note12100
10 Mar 2026OK14000

Since March 2026

Check results on CRAN

Total downloads in the last 30 days
58,819+26.7% up on the 30 days before, the better directionIt is the sum of 6 channels: CRAN, r2u, autoCRAN, conda-forge, Bioconda and c2d4u.

CRAN rank

813 of 26,530

CRAN

18,930 downloads in the last 30 days

Rank
813 of 26,530
Change
−1.8% down on the 30 days before, the worse direction

It is in the total. Take it out

r2u

2,284 downloads in the last 30 days

Rank
574 of 30,526
Change
+217% up on the 30 days before, the better direction

It is in the total. Take it out

autoCRAN

3 downloads in the last 30 days

Rank
17,776 of 29,212
Change
−66.7% down on the 30 days before, the worse direction

It is in the total. Take it out

conda-forge

37,500 downloads in the last 30 days

Rank
210 of 3,828
Change
+42.7% up on the 30 days before, the better direction

It is in the total. Take it out

Bioconda

42 downloads in the last 30 days

Rank
3,467 of 4,976
Change
−20.8% down on the 30 days before, the worse direction

It is in the total. Take it out

c2d4u, no longer updated

60 downloads in the last 30 days

Rank
431 of 7,575
Change
−21.1% down on the 30 days before, the worse direction

It is in the total. Take it out

Over time

Compare downloads

Needs
1
Dependent packages
5
Suggested by
10
Needs (1)
  • methods
Installing it adds
0 packages, 0 KB of source
Of those, need compilation
0
Optional extras (4)
Dependent packages (5)
PackageTitleDownloads in 30 days
numbatHaplotype-Aware CNV Analysis from scRNA-Seq506
plinkQCGenotype Quality Control with 'PLINK'454
fmriqaFunctional MRI Quality Assurance Routines265
RIbenchBenchmark Suite for Indirect Methods for RI Estimation237
dynafluxrRetrieve Reaction Rate Dynamics from Metabolite Concentration Time Courses190
Functions
47
Public exports
9
Lines of R code
1,315
Median complexity
2
Functions (47)
Size and composition

Lines by kind (3,074)

KindLinesShare
R code1,31543%
Tests1,08835%
Documentation52917%
Guides1425%

Lines by language

LanguageLinesShare
R2,12769%
Rd52917%
Markdown2468%
Vignettes1425%
Other301%

Languages are counted from file extensions.

Files
34
R functions
47
Object systems
S4: 2 classes, S4: 1 generics, S4: 1 methods
Complexity
Median
2
Mean
3.62
Highest
23
Median lines per function
13
About complexity

Cyclomatic complexity counts the independent paths through a function: 1 is a straight line, higher is harder to test. R functions only.

Call graph figures
R functions
47
Calls
53
Unconnected
5
Groups
1
Growth (22 releases)
Total lines by release
908 on 27 Jul 20093,074 on 17 Apr 2026
Release changes

The tests ran and coverage was measured.

Lines run by tests
98.3%
Expressions run by tests
97.7%
Test cases
35
Exports named in tests
77.8%
Coverage by file (2)
Coverage run
Lines counted
661
Lines the tests ran
650
Tests passed
Yes
Measured with
covr 3.6.5 on R 4.6.1
Test suite
Has tests
Yes
Test frameworks
testthat
Test cases
35
Snapshot tests
31
Lines of tests
1,088
Test lines per line of code
0.83
Exports documented
100%
Arguments documented
93.3%
Return value documented
83.3%
Help pages with examples
50%
Examples run in checks
100%
Guides (1)
Other documentation
README
Yes, 560 words
Release notes file
Yes
Help pages
8
Lines of documentation
529
Earlier names (11)
  • Jim Nikelski.
  • Kirill Müller.
  • Peter Humburg.
  • Rich FitzJohn.
  • some documentation
  • the Python Software Foundation.
  • the Python Software Foundation. Contributions from Steve Lianoglou
  • Trevor Davis. "getopt" function
  • Trevor Davis. Some documentation
  • Trevor L Davis
  • Trevor L Davis. Some documentation

trevorld / r-optparse on github.com

Stars
159no change on 30 days ago
Forks
10
Open issues
1
Last commit
9 May 2026
Activity
Commits
178
Open pull requests
0
Tagged releases
10
Latest tagged release
v1.8.2, 17 Apr 2026
Issues closed in
2 days (median)
Pull requests closed in
1 day (median)
Pull requests merged
84%
Created
4 May 2013
Licence file reads as
GPL-2.0
Development practices (14)
KindFound
Continuous integrationGitHub Actions, R CMD check workflow
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Governance and communityContributing guide, Funding
Funding links: GitHub Sponsors
The repository owner accepts GitHub Sponsors
Docs sourcepkgdown
CoverageCoverage reporting
Reproducibility and dev environmentdata-raw/
CRAN release processcran-comments.md
Automation and maintenancepre-commit
Lint, format, editorlintr, Lint workflow, Air, EditorConfig

Method, repository practices

Across trevorld

Claude Codeat least 13 crediting itClaude CodeFirst seen 17 Mar 2026at least 13 crediting it
Claude Sonnet 4.6Claude Sonnet 4.621 Mar 2026 to 27 Mar 202613 commits

Tools

ToolFirst seenFoundCommits crediting it
Claude Code17 Mar 2026Named in .Rbuildignore.claudeNamed in .gitignore.claude13 at least
  • Named in .Rbuildignore
  • Named in .gitignore

Models

ModelCommitsFirst commitLast commitCredit lines of
Claude Sonnet 4.61321 Mar 202627 Mar 2026Claude Code

Across trevorld

R releases
  • On CRAN
  • Release
VersionReleasedR
1.8.2 current17 Apr 20264.5.3
1.7.516 Apr 20244.3.3
1.7.416 Jan 20244.3.2
1.7.320 Jul 20224.2.1
1.7.18 Oct 20214.1.1
1.6.616 Apr 20203.6.3
1.6.416 Sep 20193.6.1
1.6.23 Apr 20193.5.3
Earlier versions (14)
VersionReleasedR
1.6.115 Jan 20193.5.2
1.6.017 Jun 20183.5.0
1.4.419 Jul 20173.4.1
1.3.23 Oct 20153.2.2
1.3.011 Dec 20143.1.2
1.2.04 Apr 20143.0.3
1.0.226 Aug 20133.0.1
1.0.130 Jan 20132.15.2
1.0.021 Nov 20122.15.2
0.9.516 Feb 20122.14.1
0.9.41 Oct 20112.13.2
0.9.14 Oct 20102.11.1
0.9.06 Aug 20102.11.1
0.83 Nov 20092.10.0
Release notes (1.8.2)

New features

------------

  • add_option() (and make_option()) now support the following new actions (#22):
  • action = "append" which appends each occurrence's value to default.
  • action = "append_const" which appends const to default each time the flag is seen.
  • action = "count", which counts the number of times a flag is seen and adds it to default (treated as 0L if not supplied). Returns NULL if the flag is never seen and no default was supplied.
  • action = "store_const" which stores const when the flag is seen.
  • add_option() (and make_option()) now support a const parameter (intended for new actions "append_const" and "store_const").
  • Several new classed errors are now thrown, mirroring Python's optparse exception hierarchy:
  • optparse_option_error: invalid option definition in make_option() or add_option().
  • optparse_option_conflict_error: duplicate flag in OptionParser() or add_option().
  • optparse_parse_error: existing base class for all parse-time errors from parse_args().
  • optparse_bad_option_error: unrecognized, misused, or argument-requiring option.
  • optparse_ambiguous_option_error: ambiguous abbreviated long flag.
  • optparse_bad_positional_arguments_error: wrong number of positional arguments supplied.
  • optparse_missing_required_error: a required option was not supplied.
  • add_option() (and make_option()) now allow non-letter characters in short flags (e.g., -1) and at the beginning of long flags (e.g., --1flag), following Python's optparse convention. However long and short flags may not contain = or whitespace (or begin with hyphens).
  • add_option() (and make_option()) now support a required argument. If TRUE, parse_args() will throw an error if the option is not provided on the command line (#17).

Bug fixes and minor improvements

--------------------------------

  • parse_args() (and parse_args2()) now correctly handle a bare -- separator: all arguments after -- are treated as positional arguments rather than options.
  • parse_args() (and parse_args2()) now support abbreviated long flags (e.g. --verb matching --verbose) when positional_arguments is not FALSE. Previously abbreviations were only supported when positional_arguments = FALSE.
  • make_option() now throws a classed optparse_option_error for invalid action or type arguments instead of a confusing error later at parse time.
  • OptionParser() now also checks the LITTLER_SCRIPT_PATH environment variable for the script name when performing %prog on the usage argument so it works when called from littler.