Home

Awesome

cpp-optparse

This is yet another option parser for C++. It is modelled after the excellent Python optparse API. Although incomplete, anyone familiar to optparse should feel at home.

Design decisions

FAQ

Future work

Example

using optparse::OptionParser;

OptionParser parser = OptionParser() .description("just an example");

parser.add_option("-f", "--file") .dest("filename")
                  .help("write report to FILE") .metavar("FILE");
parser.add_option("-q", "--quiet")
                  .action("store_false") .dest("verbose") .set_default("1")
                  .help("don't print status messages to stdout");

optparse::Values options = parser.parse_args(argc, argv);
vector<string> args = parser.args();

if (options.get("verbose"))
    cout << options["filename"] << endl;