Package 'arg'

Title: A simple modern interface to command line arguments
Description: This package provides a wrapper around {optparse} to easily handle command line arguments.
Authors: Bart Rogiers [cre, aut] (ORCID: <https://orcid.org/0000-0002-8836-0988>, url: <https://rogiersbart.github.io>), SCK CEN [cph, fnd]
Maintainer: Bart Rogiers <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2026-06-05 08:49:27 UTC
Source: https://github.com/rogiersbart/arg

Help Index


Argument count

Description

Access the number of arguments in the argument vector.

Usage

c()

Value

The number of raw arguments provided in the command line call.

Examples

assignInNamespace("arguments", base::c("one", "two","three"), "arg") # for interactive testing
arg::v()

Hello, World!

Description

Prints 'Hello, world!'.

Usage

hello()

Examples

hello()

Argument vector

Description

Access the argument vector. If an argument(s) and/or option(s) specification is provided, the argument vector is preprocessed first, and a named list with arguments and options is returned instead.

Usage

v(..., title = "Documentation", header = "", footer = "", expose = FALSE)

Arguments

...

A tibble::tribble() argument(s) and/or option(s) specification, with name, short, long, default, type and help columns.

title

The title for the documentation.

header

An introductory header for the documentation.

footer

A closing footer for the documentation.

expose

Should the arguments and options be attached to the calling environment instead of being returned as a named list?

Value

A named list of processed options and arguments, except if ... is not defined, in case which the raw argument vector is returned, or if expose is TRUE, in case which the options and arguments are attached to the calling environment and nothing is returned.

Examples

assignInNamespace("arguments", base::c("one", "2", "-o", "-h"), "arg") # for interactive testing
arg::v(
  ~name, ~short, ~long, ~default, ~type, ~help,
  "arg1", NA, NA, "default_arg1_value", "character", "First argument",
  "arg2", NA, NA, "1", "integer", "Second argument",
  "opt1", "o", "option1", NA, "logical", "Logical option",
  "opt2", "p", "option2", "Default", "character", "Character option",
  header = "This command line tool provides functionality to ..."
)