diff -r c6d537888fe5 -r df6a32249b46 demo/arg_parser_demo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/arg_parser_demo.cc Sat Mar 03 12:05:05 2007 +0000 @@ -0,0 +1,53 @@ +#include + +using namespace lemon; +int main(int argc, char **argv) +{ + ArgParser ap(argc,argv); + int i; + std::string s; + double d; + bool b,sil; + bool g1,g2,g3; + ap.option("n", "an integer input", i, true) + .option("val", "a double input", d) + .synonym("vals","val") + .option("name", "a string input", s) + .option("f", "a switch", b) + .option("nohelp", "", sil) + .option("gra","Choise A",g1) + .option("grb","Choise B",g2) + .option("grc","Choise C",g3) + .optionGroup("gr","gra") + .optionGroup("gr","grb") + .optionGroup("gr","grc") + .mandatoryGroup("gr") + .onlyOneGroup("gr") + .other("infile","The input file") + .other("..."); + + ap.parse(); + + std::cout << "Parameters of '" << ap.commandName() << "':\n"; + + if(ap.given("n")) std::cout << " Value of -n: " << i << std::endl; + if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl; + if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl; + if(ap.given("f")) std::cout << " -f is given\n"; + if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << sil << std::endl; + + switch(ap.files().size()) { + case 0: + std::cout << " No file argument was given.\n"; + break; + case 1: + std::cout << " 1 file argument was given. It is:\n"; + break; + default: + std::cout << " " + << ap.files().size() << " file arguments were given. They are:\n"; + } + for(unsigned int i=0;i