5 #include "boost/filesystem.hpp" 6 #include "boost/version.hpp" 7 #include "boost/program_options.hpp" 12 namespace fs = boost::filesystem;
13 namespace po = boost::program_options;
19 if (!fs::exists(
file)) {
20 cerr <<
"Didn't find configuration file " <<
file <<
'\n';
27 cout.setstate(ios_base::failbit);
32 cerr.setstate(ios_base::failbit);
42 help.add_options()(
"help,h",
"Help screen")(
"example,e",
"Print example of config in JSON format")(
43 "tutorial,t",
"Explain how to use the command");
48 "dry,d", po::bool_switch(&dry)->default_value(
false),
"Set up everything, but don't run anything")(
49 "verbose,v", po::bool_switch()->default_value(
false)->notifier(
set_verbose),
"Enable standard output stream")(
50 "silent,s", po::bool_switch()->default_value(
false)->notifier(
set_silent),
"Disable standard error stream");
54 pos_hide.add(
"config", 1);
57 hide.add_options()(
"key,k", po::value<string>(&
key)->
required(),
"key");
58 pos_hide.add(
"key", 1);
63 po::options_description
options;
66 po::command_line_parser parser_helper{
argc,
argv};
69 .allow_unregistered();
73 po::store(parser_helper.run(), vm);
76 if (vm.count(
"help")) {
78 cout <<
"Basic syntax:\n " << executable.filename().string() <<
" config.JSON\n" 80 <<
"Boost " << BOOST_LIB_VERSION << endl;
84 if (vm.count(
"example")) {
85 static const char *
bold =
"\e[1m", *
normal =
"\e[0m";
86 cout <<
bold <<
"Example of HTC condor config:" <<
normal <<
'\n' << endl;
87 system(
"cat $CMSSW_BASE/src/Alignment/OfflineValidation/bin/.default.sub");
88 cout <<
'\n' <<
bold <<
"Example of JSON config (for `validateAlignment` only):" <<
normal <<
'\n' << endl;
89 system(
"cat $CMSSW_BASE/src/Alignment/OfflineValidation/bin/.example.JSON");
92 <<
" for examples of inputs to GCPs, DMRs, etc., just make a dry run of the example" << endl;
97 if (vm.count(
"tutorial")) {
98 cout <<
" ______________________\n" 99 <<
" < Oops! not ready yet! >\n" 100 <<
" ----------------------\n" 102 <<
" \\ (oo)\\_______\n" 103 <<
" (__)\\ )\\/\\\n" 112 po::options_description cmd_line;
118 po::variables_map vm;
119 po::store(
parser.run(), vm);
static const char * normal
dictionary config
Read in AllInOne config in JSON format.
void check_file(string file)
void set_verbose(bool flag)
boost::program_options::options_description hide
boost::program_options::options_description help
std::vector< std::shared_ptr< fireworks::OptionNode > > Options
boost::program_options::options_description desc
void set_silent(bool flag)
bool check_file(std::string const &file)
void helper(int argc, char *argv[])
void parser(int argc, char *argv[])
boost::program_options::positional_options_description pos_hide