arg_parser.h: A command line argument parser.
dist_log.h: A tool for measuring one and two dimensional distributions.
1 #include <lemon/arg_parser.h>
4 int main(int argc, char **argv)
6 ArgParser ap(argc,argv);
12 ap.option("n", "an integer input", i, true)
13 .option("val", "a double input", d)
14 .synonym("vals","val")
15 .option("name", "a string input", s)
16 .option("f", "a switch", b)
17 .option("nohelp", "", sil)
18 .option("gra","Choise A",g1)
19 .option("grb","Choise B",g2)
20 .option("grc","Choise C",g3)
21 .optionGroup("gr","gra")
22 .optionGroup("gr","grb")
23 .optionGroup("gr","grc")
26 .other("infile","The input file")
31 std::cout << "Parameters of '" << ap.commandName() << "':\n";
33 if(ap.given("n")) std::cout << " Value of -n: " << i << std::endl;
34 if(ap.given("val")) std::cout << " Value of -val: " << d << std::endl;
35 if(ap.given("name")) std::cout << " Value of -name: " << s << std::endl;
36 if(ap.given("f")) std::cout << " -f is given\n";
37 if(ap.given("nohelp")) std::cout << " Value of -nohelp: " << sil << std::endl;
39 switch(ap.files().size()) {
41 std::cout << " No file argument was given.\n";
44 std::cout << " 1 file argument was given. It is:\n";
48 << ap.files().size() << " file arguments were given. They are:\n";
50 for(unsigned int i=0;i<ap.files().size();++i)
51 std::cout << " '" << ap.files()[i] << "'\n";