aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-09 21:49:07 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-09 21:49:07 +0100
commitd77e16ed3dd9f91728a44f8add2d32e8194a2707 (patch)
tree942b19a3a47f921791f6f81a1f126752a3c67bf6
parented7742996de320dfb33c02aa134f5ac937c6eba5 (diff)
downloadpaludis-d77e16ed3dd9f91728a44f8add2d32e8194a2707.tar.gz
paludis-d77e16ed3dd9f91728a44f8add2d32e8194a2707.tar.xz
cave print-packages --repository --category
-rw-r--r--src/clients/cave/cmd_print_packages.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/clients/cave/cmd_print_packages.cc b/src/clients/cave/cmd_print_packages.cc
index 87f90a4..499abc4 100644
--- a/src/clients/cave/cmd_print_packages.cc
+++ b/src/clients/cave/cmd_print_packages.cc
@@ -58,6 +58,19 @@ namespace
{
return "Prints a list of package names. No formatting is used, making the output suitable for parsing by scripts.";
}
+
+ args::ArgsGroup g_filters;
+ args::StringSetArg a_repository;
+ args::StringSetArg a_category;
+
+ PrintPackagesCommandLine() :
+ g_filters(main_options_section(), "Filters", "Filter the output. Each filter may be specified more than once."),
+ a_repository(&g_filters, "repository", 'r', "Show only names in the specified repository.",
+ args::StringSetArg::StringSetArgOptions()),
+ a_category(&g_filters, "category", 'c', "Show only names in the specified category.",
+ args::StringSetArg::StringSetArgOptions())
+ {
+ }
};
}
@@ -84,10 +97,20 @@ PrintPackagesCommand::run(
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories());
r != r_end; ++r)
{
+ if (cmdline.a_repository.specified())
+ if (cmdline.a_repository.end_args() == std::find(
+ cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify((*r)->name())))
+ continue;
+
std::shared_ptr<const CategoryNamePartSet> categories((*r)->category_names());
for (CategoryNamePartSet::ConstIterator c(categories->begin()), c_end(categories->end());
c != c_end; ++c)
{
+ if (cmdline.a_category.specified())
+ if (cmdline.a_category.end_args() == std::find(
+ cmdline.a_category.begin_args(), cmdline.a_category.end_args(), stringify(*c)))
+ continue;
+
std::shared_ptr<const QualifiedPackageNameSet> packages((*r)->package_names(*c));
std::copy(packages->begin(), packages->end(), std::inserter(all_packages, all_packages.begin()));
}