aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-01 19:43:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-01 19:43:13 +0000
commitd962c866741ce3c91ee1bb66d1b2569701ad9575 (patch)
treeeb23e1fac3ca30928bc99a8eb95dd33971268025
parent48334501972cb8a1028a5e8bdb49657273587a89 (diff)
downloadpaludis-d962c866741ce3c91ee1bb66d1b2569701ad9575.tar.gz
paludis-d962c866741ce3c91ee1bb66d1b2569701ad9575.tar.xz
Tell the user if they try to query a set.
-rw-r--r--src/query.cc35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/query.cc b/src/query.cc
index 979aa0e..b26e2c3 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -35,6 +35,19 @@ using std::cout;
using std::cerr;
using std::endl;
+namespace
+{
+ struct CannotQueryPackageSet
+ {
+ const std::string query;
+
+ CannotQueryPackageSet(const std::string & q) :
+ query(q)
+ {
+ }
+ };
+}
+
void do_one_query(
const p::Environment * const env,
const std::string & q)
@@ -43,10 +56,17 @@ void do_one_query(
/* we might have a dep atom, but we might just have a simple package name
* without a category. either should work. */
- p::PackageDepAtom::Pointer atom(std::string::npos == q.find('/') ?
- new p::PackageDepAtom(env->package_database()->fetch_unique_qualified_package_name(
- p::PackageNamePart(q))) :
- new p::PackageDepAtom(q));
+ p::PackageDepAtom::Pointer atom(0);
+ if (std::string::npos == q.find('/'))
+ {
+ if (0 != env->package_set(q))
+ throw CannotQueryPackageSet(q);
+ else
+ atom.assign(new p::PackageDepAtom(env->package_database()->fetch_unique_qualified_package_name(
+ p::PackageNamePart(q))));
+ }
+ else
+ atom.assign(new p::PackageDepAtom(q));
p::PackageDatabaseEntryCollection::ConstPointer
entries(env->package_database()->query(atom, p::is_either)),
@@ -246,6 +266,13 @@ int do_query()
cerr << " * " << colour(cl_package_name, *o) << endl;
cerr << endl;
}
+ catch (const CannotQueryPackageSet & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * Target '" << e.query << "' is a set, not a package." << endl;
+ cerr << endl;
+ }
catch (const p::NameError & e)
{
return_code |= 1;