aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 20:24:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 20:24:05 +0100
commit5f44815cec35b202bd824f222512305656657ae4 (patch)
treebb78fbf164d3cb7074bb90da8d3da9c803b7aad9
parentd14c32052a3e4d6c3d16669aa6760d0b0955de3c (diff)
downloadpaludis-5f44815cec35b202bd824f222512305656657ae4.tar.gz
paludis-5f44815cec35b202bd824f222512305656657ae4.tar.xz
Allow wildcards for paludis --query.
-rw-r--r--src/clients/paludis/query.cc29
-rw-r--r--src/output/console_query_task.cc23
-rw-r--r--src/output/console_query_task.hh2
3 files changed, 43 insertions, 11 deletions
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 39e8b63..d8caf96 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -131,7 +131,7 @@ void do_one_query(
try
{
do_one_package_query(env, masks_to_explain, make_shared_ptr(new PackageDepSpec(
- parse_user_package_dep_spec(q, env.get(), UserPackageDepSpecOptions() + updso_throw_if_set))));
+ parse_user_package_dep_spec(q, env.get(), UserPackageDepSpecOptions() + updso_throw_if_set + updso_allow_wildcards))));
}
catch (const GotASetNotAPackageDepSpec &)
{
@@ -186,16 +186,23 @@ int do_query(std::tr1::shared_ptr<Environment> env)
{
cerr << " Looking for suggestions:" << endl;
- FuzzyCandidatesFinder f(*env, e.name(), filter::All());
-
- if (f.begin() == f.end())
- cerr << "No suggestions found." << endl;
- else
- cerr << "Suggestions:" << endl;
-
- for (FuzzyCandidatesFinder::CandidatesConstIterator c(f.begin()),
- c_end(f.end()) ; c != c_end ; ++c)
- cerr << " * " << colour(cl_package_name, *c) << endl;
+ try
+ {
+ FuzzyCandidatesFinder f(*env, e.name(), filter::All());
+
+ if (f.begin() == f.end())
+ cerr << "No suggestions found." << endl;
+ else
+ cerr << "Suggestions:" << endl;
+
+ for (FuzzyCandidatesFinder::CandidatesConstIterator c(f.begin()),
+ c_end(f.end()) ; c != c_end ; ++c)
+ cerr << " * " << colour(cl_package_name, *c) << endl;
+ }
+ catch (const PackageDepSpecError &)
+ {
+ cerr << "Query too complicated or confusing to make suggestions." << endl;
+ }
}
cerr << endl;
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index bcef223..37c3e0b 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -73,6 +73,29 @@ ConsoleQueryTask::~ConsoleQueryTask()
void
ConsoleQueryTask::show(const PackageDepSpec & a, std::tr1::shared_ptr<const PackageID> display_entry) const
{
+ /* we might be wildcarded. */
+ if (! a.package_ptr())
+ {
+ std::tr1::shared_ptr<const PackageIDSequence> entries(
+ (*_imp->env)[selection::BestVersionOnly(generator::Matches(a))]);
+ if (entries->empty())
+ throw NoSuchPackageError(stringify(a));
+
+ for (PackageIDSequence::ConstIterator i(entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
+ {
+ PartiallyMadePackageDepSpec p(a);
+ p.package((*i)->name());
+ show_one(p, display_entry);
+ }
+ }
+ else
+ show_one(a, display_entry);
+}
+
+void
+ConsoleQueryTask::show_one(const PackageDepSpec & a, std::tr1::shared_ptr<const PackageID> display_entry) const
+{
/* prefer the best installed version, then the best visible version, then
* the best version */
std::tr1::shared_ptr<const PackageIDSequence>
diff --git a/src/output/console_query_task.hh b/src/output/console_query_task.hh
index ac0a636..e0c2abd 100644
--- a/src/output/console_query_task.hh
+++ b/src/output/console_query_task.hh
@@ -40,6 +40,8 @@ namespace paludis
protected:
ConsoleQueryTask(const Environment * const env);
+ virtual void show_one(const PackageDepSpec &, std::tr1::shared_ptr<const PackageID> = std::tr1::shared_ptr<const PackageID>()) const;
+
public:
virtual ~ConsoleQueryTask();