From: Christian P. <cp...@us...> - 2005-01-21 10:27:12
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5366/test Modified Files: CmdLineTest.cpp Log Message: Updated the CmdLineTest app. Index: CmdLineTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/CmdLineTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CmdLineTest.cpp 20 Jan 2005 19:56:30 -0000 1.2 +++ CmdLineTest.cpp 21 Jan 2005 10:26:55 -0000 1.3 @@ -20,25 +20,28 @@ #include "Test.h" #include "pclasses/App/CmdLine.h" +#include "Test.h" using namespace P; using namespace P::App; -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, - &cmdLineVal1, - &cmdLineVal2, - 0 -}; - int main(int argc, char* argv[]) { + CmdLineFlag cmdLineHelp("h", "help", "Show this help"); + CmdLineFlag cmdLineOpt1("f", "flag", "Test flag (optional)"); + CmdLineValue cmdLineVal1("v", "value", "Test value"); + + CmdLineValue cmdLineVal2("v2", "value2", "Test value with default"); + cmdLineVal2.setValue("default"); + + CmdLineOption* opts[] = { + &cmdLineOpt1, + &cmdLineVal1, + &cmdLineVal2, + 0 + }; + CmdLineParser p(opts); try { @@ -47,8 +50,19 @@ catch(CmdLineError& err) { std::cout << err.what() << std::endl; - std::cout << "Usage:" << std::endl; + std::cout << "Available options:" << std::endl; + p.dumpHelp(std::cout); + } + + if(cmdLineHelp.isset()) + { p.dumpHelp(std::cout); } + else + { + std::cout << "f set: " << cmdLineOpt1.isset() << std::endl; + std::cout << "v value: '" << cmdLineVal1.value() << "'" << std::endl; + std::cout << "v2 value: '" << cmdLineVal2.value() << "'" << std::endl; + } } |