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[])
17 std::ostringstream descstr;
18 descstr << *argv <<
" <-c <config-file>> <other-options>";
20 bpo::options_description desc = descstr.str();
22 desc.add_options()(
"config,c", bpo::value<std::string>(),
"Configuration file.")(
"help,h",
23 "produce help message");
25 bpo::variables_map vm;
29 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
32 catch (bpo::error
const& e)
34 std::cerr <<
"Exception from command line processing in " << *argv <<
": " << e.what() <<
"\n";
38 if (vm.count(
"help") != 0u)
40 std::cout << desc << std::endl;
43 if (vm.count(
"config") == 0u)
45 std::cerr <<
"Exception from command line processing in " << *argv <<
": no configuration file given.\n"
46 <<
"For usage and an options list, please do '" << *argv <<
" --help"
55 ParameterSet complete_pset;
57 if (getenv(
"FHICL_FILE_PATH") ==
nullptr)
59 std::cerr <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
60 setenv(
"FHICL_FILE_PATH",
".", 0);
63 auto file_name = vm[
"config"].as<std::string>();
64 auto filepath_maker = cet::filepath_lookup(
"FHICL_FILE_PATH");
66 make_ParameterSet(file_name, filepath_maker, complete_pset);
68 std::cout << complete_pset.to_indented_string(0,
false) <<
"\n";
73 catch (std::exception
const& x)
75 std::cerr <<
"Exception (type std::exception) caught in driver: " << x.what() <<
"\n";