#include <iostream>
{
po::options_description config("Configuration");
config.add_options()
("compression", var<int>(), "set compression level")
("optimization", var<int>(10, &opt), "optimization level")
("test-def", var<int>(42), "optimization level")
("include-path,I", vars<string>(), "include path")
("test,T", vars<string>(), "include path")
("file1", vars<string>(), "include path")
("int1", var<int>(), "include path")
("Int2", var<int>(), "include path")
("Int1", var<int>(), "include path")
("test-db", var<string>("database"), "include path")
("float1", var<double>(), "include path")
("radec", po::value<vector<double>>(), "include path")
("bool", var<bool>()->implicit_value(true), "include path")
;
po::options_description sections("Sections");
config.add_options()
("unregistered", var<string>(), "include path")
("Section1.unregistered", var<string>(), "include path")
;
po::options_description hidden("Hidden options");
hidden.add_options()
("input-file", vars<string>(), "input file")
("output-file", vars<string>(), "output file")
("test-file", vars<string>(), "test file")
;
po::options_description env("Environment options");
env.add_options()
("linux", var<string>(), "LINUX env")
("path", var<string>(), "PATH env")
("dns", var<string>(), "DIM_DNS_SERVER env")
;
conf.
AddEnv(
"linux",
"LINUX");
conf.
AddEnv(
"dns",
"DIM_DNS_SERVER");
po::positional_options_description p;
p.add("output-file", 2);
p.add("test-file", 3);
p.add("input-file", -1);
}
int main(
int argc,
const char **argv)
{
int opt;
po::variables_map vm;
try
{
vm = conf.
Parse(argc, argv);
}
catch (std::exception &e)
{
#if BOOST_VERSION > 104000
po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
if (MO)
cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
else
#endif
cout << "Error: " << e.what() << endl;
cout << endl;
return -1;
}
return -1;
cout << "------------------------------" << endl;
cout << "Program " << argv[0] << " started successfully." << endl;
cout << conf.
Has(
"switch") <<
" " << conf.
Get<
bool>(
"switch") << endl;
cout << conf.
Has(
"bool") <<
" " << conf.
Get<
bool>(
"bool") << endl;
return 0;
}