opt: Specify an option in long or short form

optR Documentation

Specify an option in long or short form

Description

This function specifies an option that is accepted by an argument parser. The results of one or more calls to this function are typically passed to arrg().

Usage

opt(label, description, arg = FALSE, default = NA_character_)

Arguments

label

A short-form (single character) and/or long-form label for the option, specified comma-separated in a single string. At most one of each form must be given. Leading hyphens are optional.

description

A textual description of the option, for use in the usage summary.

arg

The name of the option's argument, if it takes one. Otherwise FALSE, indicating no argument.

default

A default value for the argument, if one is accepted. This does not have to be a string, and arguments will be coerced to match the mode of the default when parsed. If the option takes no argument the default value will be FALSE.

Value

A data frame giving details of the option. This will not usually be used directly, but passed to arrg().

Author(s)

Jon Clayden

See Also

arrg()

Examples

  # A simple flag-style option with no argument
  opt("h,help", "Display this usage information and exit")
  
  # An option that takes an integer argument called "count"
  opt("n,times", "Run this many times", arg="count", default=1L)


arrg documentation built on Sept. 25, 2024, 5:07 p.m.

Related to opt in arrg...