2 #include "fhiclcpp/ParameterSet.h"
4 #include <boost/program_options.hpp>
7 namespace bpo = boost::program_options;
9 int main(
int argc,
char* argv[])
try
15 std::ostringstream descstr;
16 descstr << *argv <<
" <-c <config-file>> <other-options>";
18 bpo::options_description desc = descstr.str();
20 desc.add_options()(
"config,c", bpo::value<std::string>(),
"Configuration file.")(
"help,h",
21 "produce help message");
23 bpo::variables_map vm;
27 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
30 catch (bpo::error
const& e)
32 std::cerr <<
"Exception from command line processing in " << *argv <<
": " << e.what() <<
"\n";
36 if (vm.count(
"help") != 0u)
38 std::cout << desc << std::endl;
41 if (vm.count(
"config") == 0u)
43 std::cerr <<
"Exception from command line processing in " << *argv <<
": no configuration file given.\n"
44 <<
"For usage and an options list, please do '" << *argv <<
" --help"
53 if (getenv(
"FHICL_FILE_PATH") ==
nullptr)
55 std::cerr <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
56 setenv(
"FHICL_FILE_PATH",
".", 0);
59 auto file_name = vm[
"config"].as<std::string>();
60 auto filepath_maker = cet::filepath_lookup(
"FHICL_FILE_PATH");
62 auto complete_pset = fhicl::ParameterSet::make(file_name, filepath_maker);
64 std::cout << complete_pset.to_indented_string(0,
false) <<
"\n";
69 catch (std::exception
const& x)
71 std::cerr <<
"Exception (type std::exception) caught in driver: " << x.what() <<
"\n";