mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-08-05 10:46:29 -04:00

This allows exceptions for parse errors to be propagated to the caller. Exiting the program in parse is a bad idea generally, as we have no way of knowing what cleanup needs to be done in the main program.
25 lines
443 B
C++
25 lines
443 B
C++
#include <string>
|
|
#include <iostream>
|
|
#include <algorithm>
|
|
#include "tclap/CmdLine.h"
|
|
|
|
using namespace TCLAP;
|
|
using namespace std;
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
try {
|
|
|
|
CmdLine cmd("Command description message", ' ', "0.9", false);
|
|
|
|
cmd.setExceptionHandling(false);
|
|
|
|
cmd.parse(argc, argv);
|
|
|
|
} catch (ArgException &e) { // catch any exceptions
|
|
cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
|
return 1;
|
|
}
|
|
}
|
|
|