2 #include "fhiclcpp/ParameterSet.h"
3 #include "fhiclcpp/make_ParameterSet.h"
5 #include <boost/program_options.hpp>
8 namespace bpo = boost::program_options;
11 int main(
int argc,
char* argv[])
try
17 std::ostringstream descstr;
18 descstr << argv[0] <<
" <-c <config-file>> <other-options>";
20 bpo::options_description desc = descstr.str();
23 (
"config,c", bpo::value<std::string>(),
"Configuration file.")
24 (
"help,h",
"produce help message");
26 bpo::variables_map vm;
30 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
33 catch (bpo::error
const& e)
35 std::cerr <<
"Exception from command line processing in " << argv[0]
36 <<
": " << e.what() <<
"\n";
42 std::cout << desc << std::endl;
45 if (!vm.count(
"config"))
47 std::cerr <<
"Exception from command line processing in " << argv[0]
48 <<
": no configuration file given.\n"
49 <<
"For usage and an options list, please do '"
50 << argv[0] <<
" --help"
60 ParameterSet complete_pset;
63 if (getenv(
"FHICL_FILE_PATH") ==
nullptr)
66 <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
67 setenv(
"FHICL_FILE_PATH",
".", 0);
70 auto file_name = vm[
"config"].as<std::string>();
71 auto filepath_maker = cet::filepath_lookup(
"FHICL_FILE_PATH");
73 make_ParameterSet(file_name, filepath_maker, complete_pset);
75 std::cout << complete_pset.to_indented_string(0,
false) <<
"\n";
80 catch (std::string& x)
82 std::cerr <<
"Exception (type string) caught in driver: " << x <<
"\n";
88 std::cerr <<
"Exception (type char const*) caught in driver: " << std::endl;
95 std::cerr <<
"[the value was a null pointer, so no message is available]";