From: Christian P. <cp...@us...> - 2005-01-20 19:56:43
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9042/test Modified Files: CmdLineTest.cpp Log Message: Finished advanced command line parsing. Index: CmdLineTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/CmdLineTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CmdLineTest.cpp 20 Jan 2005 10:59:50 -0000 1.1 +++ CmdLineTest.cpp 20 Jan 2005 19:56:30 -0000 1.2 @@ -18,15 +18,17 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "Test.h" #include "pclasses/App/CmdLine.h" using namespace P; using namespace P::App; -CmdLineFlag cmdLineOpt1("f", "flag", false); -CmdLineValue cmdLineVal1("v", "value", "", true); -CmdLineValue cmdLineVal2("v2", "value2", "testdefault", false); +CmdLineFlag cmdLineOpt1("f", "flag", "Test flag (optional)"); +CmdLineValue cmdLineVal1("v", "value", "Test value"); +CmdLineValue cmdLineVal2("v2", "value2", "Test value with default", +"testdefault"); CmdLineOption* opts[] = { &cmdLineOpt1, @@ -38,6 +40,15 @@ int main(int argc, char* argv[]) { CmdLineParser p(opts); - p.parse(argc, argv); + try + { + p.parse(argc, argv); + } + catch(CmdLineError& err) + { + std::cout << err.what() << std::endl; + std::cout << "Usage:" << std::endl; + p.dumpHelp(std::cout); + } } |