23 #include "cetlib_except/exception.h" 39 using strings = std::vector<string>;
42 string error_filename;
44 strings input_filenames;
45 std::unique_ptr<cet::filepath_maker> policy;
49 Options process_arguments(
int argc,
char**
argv);
64 opts = process_arguments(argc, argv);
67 if (e.category() ==
help)
69 if (e.category() == processing)
89 process_arguments(
int argc,
char**
argv)
92 namespace bpo = boost::program_options;
96 bpo::options_description
desc(
"fhicl-expand <options> [files]\nOptions");
100 (
"help,h",
"produce help message")
101 (
"inputs,i", bpo::value<strings>(&opts.input_filenames),
"input files")
102 (
"output,o", bpo::value<string>(&opts.output_filename),
"output file")
103 (
"error,e", bpo::value<string>(&opts.error_filename),
"error file")
105 bpo::value<string>()->default_value(
"permissive"),
"see --supported-policies")
107 bpo::value<string>(&opts.lookup_path)->default_value(fhicl_env_var),
108 "path or environment variable to be used by lookup-policy")
109 (
"supported-policies",
"list the supported file lookup policies");
112 bpo::positional_options_description pd;
113 pd.add(
"inputs", -1);
119 if (vm.count(
"help")) {
120 std::cout << desc <<
"\n";
125 if (vm.count(
"supported-policies")) {
130 if (vm.count(
"lookup-policy") > 0) {
131 opts.policy = supported_policies.select(
132 vm[
"lookup-policy"].as<std::string>(), opts.lookup_path);
135 if (opts.input_filenames.empty())
136 opts.input_filenames.push_back(
"-");
145 std::ostream&
err)
try {
151 err <<
"Error for file: " << starting_filename <<
'\n' << e.what() <<
'\n';
ostream_handle select_stream(std::string const &filename, std::ostream &default_os)
boost::program_options::variables_map parsed_program_options(int argc, char **argv, boost::program_options::options_description const &desc, boost::program_options::positional_options_description const &pos={})
int main(int argc, char **argv)
void err(const char *fmt,...)
auto copy_all(FwdCont &, FwdIter)
int do_including(std::string const &from, std::ostream &to)
cet::coded_exception< error, detail::translate > exception
std::string help_message() const