ArgumentParser: Argument Parser

ArgumentParserR Documentation

Argument Parser

Description

Create an object of class "essentials_ArgumentParser", for parsing the command-line arguments into a more usable form.

Usage

ArgumentParser(program = NA, usage = NA, description = NA, epilogue = NA,
    add.help = TRUE,
    wrap = TRUE, indent = 0, exdent = 0,
    wrap.description = wrap,
        indent.description = indent,
        exdent.description = exdent,
    wrap.epilogue = wrap,
        indent.epilogue = indent,
        exdent.epilogue = exdent,
    style = NA, wrap.help = FALSE, help.help = default.help("help"),
    ..., help.message = NULL, n = 0)

Arguments

program

character string. The name of the program (by default, the basename of the executing script).

usage

character string. The usage of the program (by default, determined by program and any formal arguments provided by add.argument).

description, epilogue

character vector. Messages to display before and after the arguments help.

add.help

logical. Should a help option be added to the parser?

wrap.help, help.help, ...

further arguments passed to add.help.

wrap, wrap.description, wrap.epilogue

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

indent, indent.description, indent.epilogue

a non-negative integer giving the indentation of the first line in a paragraph.

exdent, exdent.description, exdent.epilogue

a non-negative integer giving the indentation of the subsequent lines in a paragraph.

style

integer. How to stylize the help message.

help.message

character vector or NULL. The help message to display. If NULL, the help message will be created from usage, description, epilogue, and any arguments provided by add.argument.

n

argument passed to try.this.path().

Details

All of the above arguments help form the documentation for your argument parser. The documentation will be printed in a similar manner to R's command-line documentation. First, the usage will be printed. This includes the name of the program (the basename of the executing script), the names of the formal arguments, and the names of the sub-commands (if any). Second, the description of the program will be printed.

An object of class "essentials_ArgumentParser" is a reference class. This allows us to use argument parsers in an almost identical manner to the argparse module from Python. All arguments to ArgumentParser are used for printing a help message.

Value

An object of class "essentials_ArgumentParser".

Methods

add.argument

Declare a formal argument for an argument parser.

add.subparsers

Declare

References

The argparse module for Python.

Examples

x <- essentials::ArgumentParser()
x$print.help()


y <- essentials::ArgumentParser(description = "A description for the program",
    epilogue = c("  --- Final Message ---   ",
        "A final message for the program, do not wrap this message"),
    wrap.epilogue = FALSE)
y$print.help()

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