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");
28 Optionpk<bool> easterEgg_opt(
"egg",
"egg",
"this help information is useless");
31 easterEgg_opt.setHide(2);
35 doProcess=foo_opt.retrieveOption(argc,argv);
36 bar_opt.retrieveOption(argc,argv);
37 easterEgg_opt.retrieveOption(argc,argv);
39 catch(std::string predefinedString){
40 std::cout << predefinedString << std::endl;
44 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
48 for(
int ifoo=0;ifoo<foo_opt.size();++ifoo){
49 std::cout << foo_opt[ifoo] <<
" ";
51 std::cout << std::endl;
52 std::cout << foo_opt << std::endl;
55 std::cout <<
"long option for bar was used with a positive value" << std::endl;
58 std::cout <<
"How did you find this option -egg or --egg? Not through the help info!" << std::endl;