arg  1.2
a C++ command-line parser
Reference Manual

This C++ library faciliates the processing of command-line arguments through an arg::Parser object. After creation, the parser is informed of options that it will parse for and their disposition. The argc and argv from the signature of main function are then passed to the parser to activate the magic.

In brief, to use the arg parser, you need to:

  1. include the header file arg.hh in your program;
  2. create a parser object (arg::Parser);
  3. add options to the parser object;
  4. pass command-line data to the parser object.

An example of simple programs using the arg parser as follows.

#include <arg.hh> // 1.
#include <iostream>
int main(int argc, char ** argv)
{
arg::Parser p; // 2.
int n;
p.add_opt('n').stow(n); // 3.
p.parse(argc, argv); // 4.
std::cout << n << '\n';
return 0;
}

This allows you to pass, on command line, an integer to the variable n in the program. The above is included as arg_ex0.cc in the examples.

Please see https://ccdw.org/~cjj/prog/arg/ for more information.

Author
Chun-Chung Chen cjj@u.nosp@m..was.nosp@m.hingt.nosp@m.on.e.nosp@m.du
arg::Parser
The command-line parser.
Definition: arg.hh:129
arg::Parser::add_opt
Option & add_opt(int key, std::string const &name="", bool hide=false)
add an Option
Definition: arg.cc:268
arg::Parser::parse
void parse(int argc, char *argv[], bool ignore_unknown=false)
perform command-line parsing
Definition: arg.cc:292
arg::Option::stow
Option & stow(T &t)
stow value to streamable variable
Definition: arg.hh:271
arg.hh
Header file for arg library.