8 #include "cetlib/container_algorithms.h" 9 #include "cetlib/filepath_maker.h" 23 pretty_version(std::string
s)
25 std::replace(s.begin(), s.end(),
'_',
'.');
32 cet::filepath_maker& maker)
33 : help_desc_{desc},
maker_{maker}
35 auto options = desc.add_options();
36 add_opt(options,
"help,h",
"produce help message");
43 options,
"config,c", bpo::value<std::string>(),
"Configuration file.");
45 options,
"process-name", bpo::value<std::string>(),
"art process name.");
49 bpo::value<std::string>(),
50 (
"List all available plugins with the provided suffix. Choose from:"s +
54 "print-available-modules",
55 "List all available modules that can be invoked in a FHiCL file.");
57 "print-available-services",
58 "List all available services that can be invoked in a FHiCL file.");
61 bpo::value<std::vector<std::string>>()->multitoken(),
62 "Print description of specified module, service, source, or other " 63 "plugin (multiple OK). Argument can be a regular expression used " 64 "to match the plugin specification. To narrow the search to " 65 "plugins with a particular suffix, preface the regular expression" 66 "with the suffix (e.g. service:TFileService).");
69 "Provide status bar that reports the progress of retrieving " 70 "plugin information for a 'print-available' command.");
78 if (vm.count(
"help")) {
84 for (std::string
s; std::getline(ss,
s);)
85 std::cout << std::string(2,
' ') <<
s <<
'\n';
89 bool const status_bar = vm.count(
"status-bar") > 0;
90 if (vm.count(
"print-available")) {
92 Suffixes::get(vm[
"print-available"].as<std::string>()), status_bar);
95 if (vm.count(
"print-available-modules")) {
99 if (vm.count(
"print-available-services")) {
105 <<
"The '--status-bar' option can be used only with the " 106 "'--print-available*' program options.\n";
109 if (vm.count(
"print-description")) {
111 vm[
"print-description"].as<std::vector<std::string>>());
114 if (vm.count(
"version")) {
119 if (!vm.count(
"config")) {
127 bpo::variables_map
const& vm,
134 std::cerr <<
"Failed to parse the configuration file '" 135 << vm[
"config"].as<std::string>() <<
"' with exception\n" 139 if (raw_config.
empty()) {
140 std::cerr <<
"INFO: provided configuration file '" 141 << vm[
"config"].as<std::string>() <<
"' is empty: \n" 142 <<
"using minimal defaults and command-line options.\n";
144 if (vm.count(
"process-name")) {
145 raw_config.
put(
"process_name", vm[
"process-name"].as<std::string>());
void add_opt(T &t, Args &&...args)
static std::string print()
int doCheckOptions(bpo::variables_map const &vm) override
shims::map< std::string, extended_value > table_t
std::string const & getReleaseVersion()
void print_available_plugins(suffix_type st, bool const verbose, std::string const &spec)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bpo::options_description const & help_desc_
std::string value(boost::any const &)
void print_descriptions(std::vector< std::string > const &plugins)
static std::string const & get(suffix_type st)
BasicOptionsHandler(bpo::options_description &desc, cet::filepath_maker &maker)
constexpr int info_success()
cet::filepath_maker & maker_
int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config) override
cet::coded_exception< error, detail::translate > exception
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)