aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-11 12:53:36 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-11 13:19:15 +0100
commit9219493289c2526d16339290fa5d49f38edfee7f (patch)
tree9668bce577294324d71c9af5f3fe994cc3f53884
parent6d18970e238796c91d23480ff4df2787d1f41321 (diff)
downloadpaludis-9219493289c2526d16339290fa5d49f38edfee7f.tar.gz
paludis-9219493289c2526d16339290fa5d49f38edfee7f.tar.xz
cave print-id-* --all
-rw-r--r--src/clients/cave/cmd_print_id_actions.cc27
-rw-r--r--src/clients/cave/cmd_print_id_contents.cc24
-rw-r--r--src/clients/cave/cmd_print_id_masks.cc27
-rw-r--r--src/clients/cave/cmd_print_id_metadata.cc13
4 files changed, 57 insertions, 34 deletions
diff --git a/src/clients/cave/cmd_print_id_actions.cc b/src/clients/cave/cmd_print_id_actions.cc
index b9ca6d2..8f02e5d 100644
--- a/src/clients/cave/cmd_print_id_actions.cc
+++ b/src/clients/cave/cmd_print_id_actions.cc
@@ -66,11 +66,13 @@ namespace
}
args::ArgsGroup g_spec_options;
+ args::SwitchArg a_all;
args::SwitchArg a_best;
PrintIDActionsCommandLine() :
g_spec_options(main_options_section(), "Spec Options", "Alter how the supplied spec is used."),
- a_best(&g_spec_options, "best", '\0', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true)
+ a_all(&g_spec_options, "all", 'a', "If the spec matches multiple IDs, display all matches.", true),
+ a_best(&g_spec_options, "best", 'b', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true)
{
add_usage_line("spec");
}
@@ -110,18 +112,21 @@ PrintIDActionsCommand::run(
if (entries->empty())
throw NothingMatching(spec);
- if ((! cmdline.a_best.specified()) && (next(entries->begin()) != entries->end()))
+ if ((! cmdline.a_best.specified()) && (! cmdline.a_all.specified())
+ && (next(entries->begin()) != entries->end()))
throw BeMoreSpecific(spec, entries);
- const std::shared_ptr<const PackageID> id(*entries->last());
-
- do_one_action<ConfigAction>(id);
- do_one_action<FetchAction>(id);
- do_one_action<InfoAction>(id);
- do_one_action<InstallAction>(id);
- do_one_action<PretendAction>(id);
- do_one_action<PretendFetchAction>(id);
- do_one_action<UninstallAction>(id);
+ for (auto i(cmdline.a_best.specified() ? entries->last() : entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
+ {
+ do_one_action<ConfigAction>(*i);
+ do_one_action<FetchAction>(*i);
+ do_one_action<InfoAction>(*i);
+ do_one_action<InstallAction>(*i);
+ do_one_action<PretendAction>(*i);
+ do_one_action<PretendFetchAction>(*i);
+ do_one_action<UninstallAction>(*i);
+ }
return EXIT_SUCCESS;
}
diff --git a/src/clients/cave/cmd_print_id_contents.cc b/src/clients/cave/cmd_print_id_contents.cc
index c249e4b..19597a2 100644
--- a/src/clients/cave/cmd_print_id_contents.cc
+++ b/src/clients/cave/cmd_print_id_contents.cc
@@ -69,6 +69,7 @@ namespace
}
args::ArgsGroup g_spec_options;
+ args::SwitchArg a_all;
args::SwitchArg a_best;
args::ArgsGroup g_filter_options;
@@ -79,7 +80,8 @@ namespace
PrintContentsCommandLine() :
g_spec_options(main_options_section(), "Spec Options", "Alter how the supplied spec is used."),
- a_best(&g_spec_options, "best", '\0', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true),
+ a_all(&g_spec_options, "all", 'a', "If the spec matches multiple IDs, display all matches.", true),
+ a_best(&g_spec_options, "best", 'b', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true),
g_filter_options(main_options_section(), "Filter Options", "Alter which contents entries are displayed."),
a_type(&g_filter_options, "type", 't', "Display only entries of the specified type",
args::EnumArg::EnumArgOptions
@@ -164,17 +166,21 @@ PrintIDContentsCommand::run(
if (entries->empty())
throw NothingMatching(spec);
- if ((! cmdline.a_best.specified()) && (next(entries->begin()) != entries->end()))
+ if ((! cmdline.a_best.specified()) && (! cmdline.a_all.specified())
+ && (next(entries->begin()) != entries->end()))
throw BeMoreSpecific(spec, entries);
- const std::shared_ptr<const PackageID> id(*entries->last());
- if (! id->contents_key())
- throw BadIDForCommand(spec, id, "does not support listing contents");
+ for (auto i(cmdline.a_best.specified() ? entries->last() : entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! (*i)->contents_key())
+ throw BadIDForCommand(spec, (*i), "does not support listing contents");
- for (auto c(id->contents_key()->value()->begin()), c_end(id->contents_key()->value()->end()) ;
- c != c_end ; ++c)
- if (match_type(cmdline.a_type, *c))
- cout << format_plain_contents_entry(*c, cmdline.a_format.argument());
+ for (auto c((*i)->contents_key()->value()->begin()), c_end((*i)->contents_key()->value()->end()) ;
+ c != c_end ; ++c)
+ if (match_type(cmdline.a_type, *c))
+ cout << format_plain_contents_entry(*c, cmdline.a_format.argument());
+ }
return EXIT_SUCCESS;
}
diff --git a/src/clients/cave/cmd_print_id_masks.cc b/src/clients/cave/cmd_print_id_masks.cc
index d8b471f..07d1291 100644
--- a/src/clients/cave/cmd_print_id_masks.cc
+++ b/src/clients/cave/cmd_print_id_masks.cc
@@ -71,6 +71,7 @@ namespace
}
args::ArgsGroup g_spec_options;
+ args::SwitchArg a_all;
args::SwitchArg a_best;
args::ArgsGroup g_filters;
@@ -82,6 +83,7 @@ namespace
PrintIDMasksCommandLine() :
g_spec_options(main_options_section(), "Spec Options", "Alter how the supplied spec is used."),
+ a_all(&g_spec_options, "all", 'a', "If the spec matches multiple IDs, display all matches.", true),
a_best(&g_spec_options, "best", '\0', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true),
g_filters(main_options_section(), "Filters", "Filter the output."),
a_overridden(&g_filters, "overridden", '\0', "Show overridden masks", true),
@@ -189,18 +191,23 @@ PrintIDMasksCommand::run(
if (entries->empty())
throw NothingMatching(spec);
- if ((! cmdline.a_best.specified()) && (next(entries->begin()) != entries->end()))
+ if ((! cmdline.a_best.specified()) && (! cmdline.a_all.specified())
+ && (next(entries->begin()) != entries->end()))
throw BeMoreSpecific(spec, entries);
- if (! cmdline.a_no_active.specified())
- for (PackageID::MasksConstIterator m((*entries->last())->begin_masks()), m_end((*entries->last())->end_masks()) ;
- m != m_end ; ++m)
- do_one_mask(*m, last_mro, cmdline);
-
- if (cmdline.a_overridden.specified())
- for (PackageID::OverriddenMasksConstIterator m((*entries->last())->begin_overridden_masks()), m_end((*entries->last())->end_overridden_masks()) ;
- m != m_end ; ++m)
- do_one_mask((*m)->mask(), (*m)->override_reason(), cmdline);
+ for (auto i(cmdline.a_best.specified() ? entries->last() : entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! cmdline.a_no_active.specified())
+ for (PackageID::MasksConstIterator m((*i)->begin_masks()), m_end((*i)->end_masks()) ;
+ m != m_end ; ++m)
+ do_one_mask(*m, last_mro, cmdline);
+
+ if (cmdline.a_overridden.specified())
+ for (PackageID::OverriddenMasksConstIterator m((*i)->begin_overridden_masks()), m_end((*i)->end_overridden_masks()) ;
+ m != m_end ; ++m)
+ do_one_mask((*m)->mask(), (*m)->override_reason(), cmdline);
+ }
return EXIT_SUCCESS;
}
diff --git a/src/clients/cave/cmd_print_id_metadata.cc b/src/clients/cave/cmd_print_id_metadata.cc
index afdbe7a..c4bafdc 100644
--- a/src/clients/cave/cmd_print_id_metadata.cc
+++ b/src/clients/cave/cmd_print_id_metadata.cc
@@ -66,6 +66,7 @@ namespace
}
args::ArgsGroup g_spec_options;
+ args::SwitchArg a_all;
args::SwitchArg a_best;
args::ArgsGroup g_filters;
@@ -77,6 +78,7 @@ namespace
PrintIDMetadataCommandLine() :
g_spec_options(main_options_section(), "Spec Options", "Alter how the supplied spec is used."),
+ a_all(&g_spec_options, "all", 'a', "If the spec matches multiple IDs, display all matches.", true),
a_best(&g_spec_options, "best", '\0', "If the spec matches multiple IDs, select the best ID rather than giving an error.", true),
g_filters(main_options_section(), "Filters", "Filter the output. Each filter may be specified more than once."),
a_raw_name(&g_filters, "raw-name", '\0', "Show only keys with this raw name. If specified more than once, "
@@ -154,12 +156,15 @@ PrintIDMetadataCommand::run(
if (entries->empty())
throw NothingMatching(spec);
- if ((! cmdline.a_best.specified()) && (next(entries->begin()) != entries->end()))
+ if ((! cmdline.a_best.specified()) && (! cmdline.a_all.specified())
+ && (next(entries->begin()) != entries->end()))
throw BeMoreSpecific(spec, entries);
- for (PackageID::MetadataConstIterator m((*entries->last())->begin_metadata()), m_end((*entries->last())->end_metadata()) ;
- m != m_end ; ++m)
- do_one_key(*m, cmdline, "");
+ for (auto i(cmdline.a_best.specified() ? entries->last() : entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
+ for (PackageID::MetadataConstIterator m((*i)->begin_metadata()), m_end((*i)->end_metadata()) ;
+ m != m_end ; ++m)
+ do_one_key(*m, cmdline, "");
return EXIT_SUCCESS;
}