aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 21:00:16 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 21:00:16 +0100
commitea0cc80ee33c07b73e88d9b832fd1f5a08afa351 (patch)
tree189054e3578c07650fb35552b054244d3a1120c5
parent9374fe23072997049534761a1e04e7de69e453a0 (diff)
downloadpaludis-ea0cc80ee33c07b73e88d9b832fd1f5a08afa351.tar.gz
paludis-ea0cc80ee33c07b73e88d9b832fd1f5a08afa351.tar.xz
Allow wildcards for --install.
-rw-r--r--paludis/install_task.cc37
-rw-r--r--src/output/console_install_task.cc23
2 files changed, 48 insertions, 12 deletions
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 9b0d137..b507318 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -385,7 +385,7 @@ InstallTask::_add_target(const std::string & target)
try
{
std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(target,
- _imp->env, UserPackageDepSpecOptions() + updso_throw_if_set,
+ _imp->env, UserPackageDepSpecOptions() + updso_throw_if_set + updso_allow_wildcards,
filter::SupportsAction<InstallAction>())));
if (_imp->had_set_targets)
@@ -394,9 +394,38 @@ InstallTask::_add_target(const std::string & target)
if (! _imp->override_target_type)
_imp->dep_list.options()->target_type = dl_target_package;
- spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
- _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
- new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
+ if (spec->package_ptr())
+ {
+ /* no wildcards */
+ spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
+ new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
+ }
+ else
+ {
+ std::tr1::shared_ptr<const PackageIDSequence> names((*_imp->env)[selection::BestVersionOnly(
+ generator::Matches(*spec) | filter::SupportsAction<InstallAction>())]);
+
+ if (names->empty())
+ {
+ /* no match. we'll get an error from this later anyway. */
+ spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
+ new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
+ }
+ else
+ for (PackageIDSequence::ConstIterator i(names->begin()), i_end(names->end()) ;
+ i != i_end ; ++i)
+ {
+ PartiallyMadePackageDepSpec p(*spec);
+ p.package((*i)->name());
+ std::tr1::shared_ptr<PackageDepSpec> specn(new PackageDepSpec(p));
+ specn->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
+ _imp->targets->add(std::tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
+ new TreeLeaf<SetSpecTree, PackageDepSpec>(specn)));
+ }
+ }
+
_imp->raw_targets.push_back(stringify(*spec));
}
catch (const GotASetNotAPackageDepSpec &)
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 540f366..8c26a5a 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -1639,16 +1639,23 @@ ConsoleInstallTask::on_all_masked_error(const AllMaskedError & e)
{
output_stream() << " Looking for suggestions:" << endl;
- FuzzyCandidatesFinder f(*environment(), stringify(e.query()), filter::SupportsAction<InstallAction>());
+ try
+ {
+ FuzzyCandidatesFinder f(*environment(), stringify(e.query()), filter::SupportsAction<InstallAction>());
- if (f.begin() == f.end())
- output_stream() << "No suggestions found." << endl;
- else
- output_stream() << "Suggestions:" << endl;
+ if (f.begin() == f.end())
+ output_stream() << "No suggestions found." << endl;
+ else
+ output_stream() << "Suggestions:" << endl;
- for (FuzzyCandidatesFinder::CandidatesConstIterator c(f.begin()), c_end(f.end())
- ; c != c_end ; ++c)
- output_stream() << " * " << colour(cl_package_name, *c) << endl;
+ for (FuzzyCandidatesFinder::CandidatesConstIterator c(f.begin()), c_end(f.end())
+ ; c != c_end ; ++c)
+ output_stream() << " * " << colour(cl_package_name, *c) << endl;
+ }
+ catch (const PackageDepSpecError &)
+ {
+ output_stream() << "Query too complicated or confusing to make suggestions." << endl;
+ }
}
}
else