add.help: Add Common Arguments to an ArgumentParser

add.helpR Documentation

Add Common Arguments to an ArgumentParser

Description

Convenience functions for adding help, skip, and version arguments to an ArgumentParser.

A help argument will print the help message when requested, a skip argument will indicate that the following arguments are for another program (and hence, will not be parsed by the parser), and a version argument will print the version of the running program.

Usage

## S4 method for signature 'essentials_ArgumentParser'
add.help(name.or.flags = c("-h", "--help"), action = "help",
    help = default.help("help"), wrap = FALSE, ...)

## S4 method for signature 'essentials_ArgumentParser'
add.skip(name.or.flags = "--args", action = "skip",
    help = default.help("skip"), wrap = FALSE, ...)

## S4 method for signature 'essentials_ArgumentParser'
add.version(name.or.flags = "--version", action = "exit",
    help = default.help("version"), wrap = FALSE, exit, ...)

Arguments

name.or.flags

character vector. The name or flags of the argument.

action

character string. Indicates what to do when this argument is encountered.

help

character vector. A brief description of the formal argument.

wrap

logical. Should the usage message help be wrapped when printing the help message for the argument parser?

exit

character vector. The text to be printed before terminating the program.

...

further arguments passed to add.argument.

Value

Invisible NULL.

Note

Unlike Python's argparse, a version argument is a specific case of an exit argument, an argument which will print an exit message before the program is terminated. For example, on Unix, the RHOME argument for the ‘R’ executable is an exit argument, and its exit message is the R home directory.


ArcadeAntics/essentials documentation built on Nov. 7, 2024, 4:33 p.m.