aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-15 15:12:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-15 15:12:52 +0000
commit7e3050875d1d1b9be634f894bf2ca08e651311bd (patch)
tree850bc38943e827e78babe7ea87b5535186d0578c
parent51020c2b143a02695abf4d29caa1fa116fc2c602 (diff)
downloadpaludis-7e3050875d1d1b9be634f894bf2ca08e651311bd.tar.gz
paludis-7e3050875d1d1b9be634f894bf2ca08e651311bd.tar.xz
Add --repository, --category, --package filter options for the --list actions
-rw-r--r--src/command_line.cc13
-rw-r--r--src/command_line.hh36
-rw-r--r--src/list.cc61
3 files changed, 93 insertions, 17 deletions
diff --git a/src/command_line.cc b/src/command_line.cc
index f05650d..3a2a9c4 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -30,17 +30,17 @@ CommandLine::CommandLine() :
a_list_repositories(&action_args, "list-repositories", '\0', "List available repositories"),
a_list_categories(&action_args, "list-categories", '\0', "List available categories"),
a_list_packages(&action_args, "list-packages", '\0', "List available packages"),
- a_list_sync_protocols(&action_args, "list-sync-protocols", '\0', "List available sync protocols"),
- a_list_repository_formats(&action_args, "list-repository-formats", '\0', "List available repository formats"),
- a_list_dep_tag_categories(&action_args, "list-dep-tag-categories", '\0', "List known dep tag categories"),
a_contents(&action_args, "contents", 'k', "Display contents of a package"),
a_owner(&action_args, "owner", 'o', "Display the owner of a file"),
a_version(&action_args, "version", 'V', "Display program version"),
a_help(&action_args, "help", 'h', "Display program help"),
- action_args_internal(this, "More actions (internal use)"),
+ action_args_internal(this, "More actions (mostly for internal / script use)"),
a_has_version(&action_args_internal, "has-version", '\0', "Check whether the specified atom is installed"),
a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified atom"),
+ a_list_sync_protocols(&action_args_internal, "list-sync-protocols", '\0', "List available sync protocols"),
+ a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0', "List available repository formats"),
+ a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories"),
a_update_news(&action_args_internal, "update-news", '\0', "Regenerate news.unread files"),
general_args(this, "General options"),
@@ -78,6 +78,11 @@ CommandLine::CommandLine() :
a_dl_no_recursive_deps(&dl_args, "dl-no-recursive-deps", '\0', "Don't check runtime dependencies for installed packages"),
a_dl_max_stack_depth(&dl_args, "dl-max-stack-depth", '\0', "Maximum stack depth (default 100)"),
+ list_args(this, "List options"),
+ a_repository(&list_args, "repository", '\0', "Matches with this repository name only"),
+ a_category(&list_args, "category", '\0', "Matches with this category name only"),
+ a_package(&list_args, "package", '\0', "Matches with this package name only"),
+
owner_args(this, "Owner options"),
a_full_match(&owner_args, "full-match", '\0', "Match whole filename")
{
diff --git a/src/command_line.hh b/src/command_line.hh
index e3ade12..b7af345 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -71,15 +71,6 @@ class CommandLine :
/// --list-packages
paludis::args::SwitchArg a_list_packages;
- /// --list-sync-protocols
- paludis::args::SwitchArg a_list_sync_protocols;
-
- /// --list-repository-formats
- paludis::args::SwitchArg a_list_repository_formats;
-
- /// --list-dep-tag-categories
- paludis::args::SwitchArg a_list_dep_tag_categories;
-
/// --contents
paludis::args::SwitchArg a_contents;
@@ -101,10 +92,18 @@ class CommandLine :
/// --best-version
paludis::args::SwitchArg a_best_version;
+ /// --list-sync-protocols
+ paludis::args::SwitchArg a_list_sync_protocols;
+
+ /// --list-repository-formats
+ paludis::args::SwitchArg a_list_repository_formats;
+
+ /// --list-dep-tag-categories
+ paludis::args::SwitchArg a_list_dep_tag_categories;
+
/// --update-news
paludis::args::SwitchArg a_update_news;
-
///}
/// \name General arguments
@@ -193,6 +192,23 @@ class CommandLine :
/// }
+ /// \name List arguments
+ /// {
+
+ /// List arguments.
+ paludis::args::ArgsGroup list_args;
+
+ /// --repository
+ paludis::args::StringSetArg a_repository;
+
+ /// --category
+ paludis::args::StringSetArg a_category;
+
+ /// --package
+ paludis::args::StringSetArg a_package;
+
+ /// }
+
/// \name Owner arguments
/// {
diff --git a/src/list.cc b/src/list.cc
index 7fd18e1..fd8bef6 100644
--- a/src/list.cc
+++ b/src/list.cc
@@ -30,6 +30,8 @@ namespace p = paludis;
int
do_list_repositories()
{
+ int ret_code(1);
+
p::Context context("When performing list-repositories action from command line:");
p::Environment * const env(p::DefaultEnvironment::get_instance());
@@ -37,6 +39,15 @@ do_list_repositories()
r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
r != r_end ; ++r)
{
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ ret_code = 0;
+
std::cout << "* " << colour(cl_package_name, r->name()) << std::endl;
for (p::Repository::InfoIterator i(r->begin_info()), i_end(r->end_info()) ; i != i_end ; ++i)
@@ -46,12 +57,14 @@ do_list_repositories()
std::cout << std::endl;
}
- return 0;
+ return ret_code;
}
int
do_list_categories()
{
+ int ret_code(1);
+
p::Context context("When performing list-categories action from command line:");
p::Environment * const env(p::DefaultEnvironment::get_instance());
@@ -61,6 +74,13 @@ do_list_categories()
r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
r != r_end ; ++r)
{
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
p::CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
for (p::CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
c != c_end ; ++c)
@@ -70,18 +90,29 @@ do_list_categories()
for (std::map<p::CategoryNamePart, std::list<p::RepositoryName > >::const_iterator
c(cats.begin()), c_end(cats.end()) ; c != c_end ; ++c)
{
+ if (CommandLine::get_instance()->a_category.specified())
+ if (CommandLine::get_instance()->a_category.args_end() == std::find(
+ CommandLine::get_instance()->a_category.args_begin(),
+ CommandLine::get_instance()->a_category.args_end(),
+ stringify(c->first)))
+ continue;
+
+ ret_code = 0;
+
std::cout << "* " << colour(cl_package_name, c->first) << std::endl;
std::cout << " " << std::setw(22) << std::left << "found in:" <<
std::setw(0) << " " << p::join(c->second.begin(), c->second.end(), ", ") << std::endl;
std::cout << std::endl;
}
- return 0;
+ return ret_code;
}
int
do_list_packages()
{
+ int ret_code(1);
+
p::Context context("When performing list-packages action from command line:");
p::Environment * const env(p::DefaultEnvironment::get_instance());
@@ -91,10 +122,24 @@ do_list_packages()
r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
r != r_end ; ++r)
{
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
p::CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
for (p::CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
c != c_end ; ++c)
{
+ if (CommandLine::get_instance()->a_category.specified())
+ if (CommandLine::get_instance()->a_category.args_end() == std::find(
+ CommandLine::get_instance()->a_category.args_begin(),
+ CommandLine::get_instance()->a_category.args_end(),
+ stringify(*c)))
+ continue;
+
p::QualifiedPackageNameCollection::ConstPointer pkg_names(r->package_names(*c));
for (p::QualifiedPackageNameCollection::Iterator p(pkg_names->begin()), p_end(pkg_names->end()) ;
p != p_end ; ++p)
@@ -105,11 +150,21 @@ do_list_packages()
for (std::map<p::QualifiedPackageName, std::list<p::RepositoryName > >::const_iterator
p(pkgs.begin()), p_end(pkgs.end()) ; p != p_end ; ++p)
{
+ if (CommandLine::get_instance()->a_package.specified())
+ if (CommandLine::get_instance()->a_package.args_end() == std::find(
+ CommandLine::get_instance()->a_package.args_begin(),
+ CommandLine::get_instance()->a_package.args_end(),
+ stringify(p->first.get<p::qpn_package>())))
+ continue;
+
+ ret_code = 0;
+
std::cout << "* " << colour(cl_package_name, p->first) << std::endl;
std::cout << " " << std::setw(22) << std::left << "found in:" <<
std::setw(0) << " " << p::join(p->second.begin(), p->second.end(), ", ") << std::endl;
std::cout << std::endl;
}
- return 0;
+ return ret_code;
}
+