7 #include "cetlib/HorizontalRule.h" 8 #include "cetlib/container_algorithms.h" 20 constexpr cet::HorizontalRule fixed_rule{100};
22 std::vector<art::detail::PluginMetadata>
23 matchesBySpec(std::string
const& specified_plugin_type,
24 std::string
const& instance_pattern)
26 std::vector<PluginMetadata> result;
27 auto collect_metadata = [&result,
32 std::back_inserter(result),
33 [&mc](
auto const& info) {
return mc->collect(info,
indent__2()); });
36 if (specified_plugin_type.empty()) {
39 collect_metadata(pr.first);
47 using Duplicates_t = std::map<std::string, std::vector<std::string>>;
49 duplicates_message(
art::suffix_type const st, Duplicates_t
const& duplicates)
52 std::string
const type_spec =
56 <<
"s marked '*' above are degenerate--i.e. specifying the short\n" 58 <<
" value leads to an ambiguity. In order to use a degenerate\n" 60 <<
", in your configuration file, give the long specification (as\n" 62 <<
"shown in the table below), surrounded by quotation (\") marks.\n\n";
63 std::size_t
const firstColW{
64 columnWidth(duplicates, &Duplicates_t::value_type::first,
"module_type")};
66 <<
std::left <<
"Long specification" <<
'\n';
67 cout <<
indent0() << fixed_rule(
'-') <<
'\n';
68 for (
auto const& dup : duplicates) {
69 auto const& long_specs = dup.second;
70 cout <<
indent0() << std::setw(firstColW + 4) << std::left << dup.first
71 << std::left << long_specs[0] <<
'\n';
72 for (
auto it = long_specs.begin() + 1,
end = long_specs.end(); it !=
end;
74 cout <<
indent0() << std::setw(firstColW + 4) <<
"\"\"" << std::left
84 std::string
const& spec)
92 cet::HorizontalRule
const rule{
rule_size(ms->widths())};
94 << rule(
'=') <<
"\n\n" 95 << ms->header() <<
"\n" 99 Duplicates_t duplicates;
100 for (
auto const& info : coll) {
101 auto summary = ms->summary(info, ++i);
102 cout << summary.message;
103 if (summary.is_duplicate)
104 duplicates[info.short_spec()].push_back(info.long_spec());
106 cout <<
"\n" << rule(
'=') <<
"\n\n";
108 if (duplicates.empty())
111 duplicates_message(st, duplicates);
117 std::string
const& spec,
118 std::string
const& key)
123 throw e << (spec.empty() ?
"[Missing specification]" :
bold_fontify(spec))
124 <<
" did not match any plugin.\n";
125 }
else if (coll.size() > 1ull) {
126 throw e <<
bold_fontify(spec) <<
" matched more than one plugin.\n" 127 <<
"When querying plugin configurations, the plugin specification\n" 128 <<
"must resolve to a unique library.\n";
130 if (
auto config = coll.begin()->allowed_config()) {
132 *config->parameter_base(), key);
140 for (
auto const& m : matches) {
141 cout << m.header() << m.details() << m.allowed_configuration();
142 cout <<
'\n' << fixed_rule(
'=') <<
"\n\n";
147 std::pair<std::string, std::string>
148 parse_specified_plugin(std::string
const& spec)
155 std::string specified_plugin_type{};
156 std::string instance_pattern{spec};
157 auto const pos = spec.find(
":");
158 if (pos != std::string::npos) {
159 specified_plugin_type = spec.substr(0, pos);
160 if (specified_plugin_type.empty()) {
162 "Error while parsing specified plugins:\n"}
163 <<
"The specification '" << spec
164 <<
"' is missing a module type before the colon (':').\n" 165 "If you intend to search through all plugin types, remove the " 166 "colon; otherwise specify\n" 167 "one of the following plugin types:" 170 instance_pattern = spec.substr(pos + 1);
172 return std::make_pair(std::move(specified_plugin_type),
173 std::move(instance_pattern));
180 cout <<
'\n' << fixed_rule(
'=') <<
"\n\n";
181 for (
auto const& spec : specs) {
182 std::string plugin_type{}, instance_pattern{};
183 std::tie(plugin_type, instance_pattern) = parse_specified_plugin(spec);
185 auto matches = matchesBySpec(plugin_type, instance_pattern);
186 if (matches.empty()) {
188 << (instance_pattern.empty() ?
"[Missing specification]" :
190 <<
" did not match any plugin";
191 cout << (plugin_type.empty() ?
"" :
" of type '" + plugin_type +
"'");
193 cout <<
'\n' << fixed_rule(
'=') <<
"\n\n";
std::string bold_fontify(std::string const &s)
static std::map< suffix_type, std::string > const & all()
std::size_t columnWidth(T const &coll, std::string const Elem::*cp, std::string const &header)
static std::string print()
std::size_t rule_size(Widths const &widths)
LibraryInfoCollection get_LibraryInfoCollection(suffix_type suffix, std::string const &pattern, bool const verbose=false)
void print_available_plugins(suffix_type st, bool const verbose, std::string const &spec)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
void print_descriptions(std::vector< std::string > const &plugins)
static std::string const & get(suffix_type st)
void print_description(std::vector< PluginMetadata > const &matches)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::unique_ptr< MetadataSummary > get_MetadataSummary(suffix_type st, LibraryInfoCollection const &coll)
static bool supports_key(ParameterBase const &pb, std::string const &searched_for_key)
bool supports_key(suffix_type st, std::string const &spec, std::string const &key)
std::unique_ptr< MetadataCollector > get_MetadataCollector(suffix_type st)