#include <string>
#include <iostream>
#include "cmdline.h"
using namespace std;
using namespace cmdl;
int main( int argc, char *argv[] )
{
// parse command line
try {
CmdLine C;
C.Init( --argc, ++argv); // mark the command line arguments
// to be parsed (without program name)
// retrieve and print an integer set with option "--set-int"
int nTest = 0;
C.GetSingleValue("--set-int", nTest);
cout << "Integer set: " << nTest << endl;
C.Done(); // check for unused options
}
// handle errors
catch (exception& e){
cout << e.what() << endl;
}
}
Executing the program above looks like this:
> cmdsample --set-int 117 Integer set: 117
More examples are found in chapter usage.