aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 20:43:41 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 20:43:41 +0100
commit9374fe23072997049534761a1e04e7de69e453a0 (patch)
tree3de8a4e60d60c6493c485bb04d4ffd79a38a3f1c
parent5f44815cec35b202bd824f222512305656657ae4 (diff)
downloadpaludis-9374fe23072997049534761a1e04e7de69e453a0.tar.gz
paludis-9374fe23072997049534761a1e04e7de69e453a0.tar.xz
Allow wildcards on --uninstall.
-rw-r--r--paludis/uninstall_task.cc34
-rw-r--r--src/clients/paludis/uninstall.cc23
2 files changed, 46 insertions, 11 deletions
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index 0b81455..89584f7 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -161,15 +161,43 @@ UninstallTask::add_target(const std::string & target)
try
{
std::tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(parse_user_package_dep_spec(
- target, _imp->env, UserPackageDepSpecOptions() + updso_throw_if_set,
+ target, _imp->env, UserPackageDepSpecOptions() + updso_throw_if_set + updso_allow_wildcards,
filter::SupportsAction<UninstallAction>())));
if (_imp->had_set_targets)
throw HadBothPackageAndSetTargets();
_imp->had_package_targets = true;
- pds->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
- _imp->targets.push_back(pds);
+ if (pds->package_ptr())
+ {
+ /* don't need to dewildcard */
+ pds->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets.push_back(pds);
+ }
+ else
+ {
+ /* blech. wildcards. */
+ std::tr1::shared_ptr<const PackageIDSequence> names((*_imp->env)[selection::BestVersionOnly(
+ generator::Matches(*pds) | filter::SupportsAction<UninstallAction>())]);
+ if (names->empty())
+ {
+ /* no match. we'll get an error from this later anyway. */
+ pds->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets.push_back(pds);
+ }
+ else
+ {
+ for (PackageIDSequence::ConstIterator i(names->begin()), i_end(names->end()) ;
+ i != i_end ; ++i)
+ {
+ PartiallyMadePackageDepSpec p(*pds);
+ p.package((*i)->name());
+ std::tr1::shared_ptr<PackageDepSpec> pdsn(new PackageDepSpec(p));
+ pdsn->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets.push_back(pdsn);
+ }
+ }
+ }
}
catch (const GotASetNotAPackageDepSpec &)
{
diff --git a/src/clients/paludis/uninstall.cc b/src/clients/paludis/uninstall.cc
index 9287594..e58b51c 100644
--- a/src/clients/paludis/uninstall.cc
+++ b/src/clients/paludis/uninstall.cc
@@ -302,16 +302,23 @@ namespace
{
cerr << " Looking for suggestions:" << endl;
- FuzzyCandidatesFinder f(*env, e.name(), filter::InstalledAtRoot(env->root()));
+ try
+ {
+ FuzzyCandidatesFinder f(*env, e.name(), filter::InstalledAtRoot(env->root()));
- if (f.begin() == f.end())
- cerr << "No suggestions found." << endl;
- else
- cerr << "Suggestions:" << endl;
+ 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;
+ 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;