A more complex example with help text
#include <iostream>
using namespace std;
string const version = "1.0";
int main(int argc, char ** argv)
{
parser.
set_header(
"arg Testing Program v" + version);
parser.
add_help(
"available options are:");
int n;
.
help(
"set number of nodes to INT",
"INT")
string f;
int f_given = 0;
.
help(
"read data from FILE",
"FILE")
parser.
add_opt_version(version);
try {
parser.
parse(argc, argv);
}
catch (arg::Error e) {
cout << "Error parsing command line: " << e.get_msg() << '\n';
return 1;
}
if (! f.size()) {
cout << "Need to specify the input file!\n";
return 1;
}
cout << "The parameters are:\n"
<< "number = " << n << '\n'
<< "input = " << f << '\n';
return 0;
}
void parse(int argc, char *argv[], bool ignore_unknown=false)
perform command-line parsing
Definition: arg.cc:292