22 #include "base/Optionpk.h"
24 int main(
int argc,
char *argv[])
26 Optionpk<std::string> foo_opt(
"f",
"foo",
"command line option **foo** of type string can be invoked with either short (f) or long (foo) option",
"defaultString");
27 Optionpk<int> bar_opt(
"\0",
"bar",
"command line option **bar** of type int has no short option",
false,1);
28 Optionpk<bool> easterEgg_opt(
"egg",
"egg",
"this help information is useless",
false,2);
32 doProcess=foo_opt.retrieveOption(argc,argv);
33 bar_opt.retrieveOption(argc,argv);
34 easterEgg_opt.retrieveOption(argc,argv);
36 catch(std::string predefinedString){
37 std::cout << predefinedString << std::endl;
41 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
45 for(
int ifoo=0;ifoo<foo_opt.size();++ifoo){
46 std::cout << foo_opt[ifoo] <<
" ";
48 std::cout << std::endl;
49 std::cout << foo_opt << std::endl;
52 std::cout <<
"long option for bar was used with a positive value" << std::endl;
55 std::cout <<
"How did you find this option -egg or --egg? Not through the help info!" << std::endl;