2 #include "fhiclcpp/ParameterSet.h"
3 #include "fhiclcpp/make_ParameterSet.h"
5 #include <boost/program_options.hpp>
8 namespace bpo = boost::program_options;
10 int main(
int argc,
char* argv[])
try
16 std::ostringstream descstr;
17 descstr << *argv <<
" <-c <config-file>> <other-options>";
19 bpo::options_description desc = descstr.str();
21 desc.add_options()(
"config,c", bpo::value<std::string>(),
"Configuration file.")(
"help,h",
22 "produce help message");
24 bpo::variables_map vm;
28 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
31 catch (bpo::error
const& e)
33 std::cerr <<
"Exception from command line processing in " << *argv <<
": " << e.what() <<
"\n";
37 if (vm.count(
"help") != 0u)
39 std::cout << desc << std::endl;
42 if (vm.count(
"config") == 0u)
44 std::cerr <<
"Exception from command line processing in " << *argv <<
": no configuration file given.\n"
45 <<
"For usage and an options list, please do '" << *argv <<
" --help"
54 ParameterSet complete_pset;
56 if (getenv(
"FHICL_FILE_PATH") ==
nullptr)
58 std::cerr <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
59 setenv(
"FHICL_FILE_PATH",
".", 0);
62 auto file_name = vm[
"config"].as<std::string>();
63 auto filepath_maker = cet::filepath_lookup(
"FHICL_FILE_PATH");
65 make_ParameterSet(file_name, filepath_maker, complete_pset);
67 std::cout << complete_pset.to_indented_string(0,
false) <<
"\n";
72 catch (std::exception
const& x)
74 std::cerr <<
"Exception (type std::exception) caught in driver: " << x.what() <<
"\n";