aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-10 12:30:40 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-10 12:30:40 +0100
commitb1fd8585ccacf68c330a286931f7ad042d9a0f50 (patch)
tree96fce479816d01f69bf6043fb059c07c4a7a4a8d
parent76a4175cc15e8ad9f7d698872424e58412307965 (diff)
downloadpaludis-b1fd8585ccacf68c330a286931f7ad042d9a0f50.tar.gz
paludis-b1fd8585ccacf68c330a286931f7ad042d9a0f50.tar.xz
Refactor
-rw-r--r--src/clients/cave/cmd_config.cc5
-rw-r--r--src/clients/cave/cmd_contents.cc2
-rw-r--r--src/clients/cave/cmd_info.cc2
-rw-r--r--src/clients/cave/cmd_perform.cc14
-rw-r--r--src/clients/cave/cmd_show.cc2
-rw-r--r--src/clients/cave/cmd_uninstall.cc2
-rw-r--r--src/clients/cave/cmd_verify.cc2
-rw-r--r--src/clients/cave/exceptions.cc11
-rw-r--r--src/clients/cave/exceptions.hh9
9 files changed, 31 insertions, 18 deletions
diff --git a/src/clients/cave/cmd_config.cc b/src/clients/cave/cmd_config.cc
index c13e0c4..6ee0d2f 100644
--- a/src/clients/cave/cmd_config.cc
+++ b/src/clients/cave/cmd_config.cc
@@ -93,12 +93,11 @@ ConfigCommand::run(
if (1 != std::distance(cmdline.begin_parameters(), cmdline.end_parameters()))
throw args::DoHelp("config takes exactly one parameter");
- PackageDepSpec spec(parse_user_package_dep_spec(*cmdline.begin_parameters(), env.get(),
- { }));
+ PackageDepSpec spec(parse_user_package_dep_spec(*cmdline.begin_parameters(), env.get(), { }));
const std::shared_ptr<const PackageIDSequence> ids((*env)[selection::AllVersionsUnsorted(
generator::Matches(spec, { }) | filter::SupportsAction<ConfigAction>())]);
if (ids->empty())
- throw NothingMatching(spec);
+ nothing_matching_error(env.get(), *cmdline.begin_parameters(), filter::SupportsAction<ConfigAction>());
else if (1 != std::distance(ids->begin(), ids->end()))
throw BeMoreSpecific(spec, ids);
const std::shared_ptr<const PackageID> id(*ids->begin());
diff --git a/src/clients/cave/cmd_contents.cc b/src/clients/cave/cmd_contents.cc
index 3cdf700..0af6e25 100644
--- a/src/clients/cave/cmd_contents.cc
+++ b/src/clients/cave/cmd_contents.cc
@@ -130,7 +130,7 @@ ContentsCommand::run(
(*env)[selection::AllVersionsSorted(generator::Matches(spec, { }) | filter::InstalledAtRoot(env->root()))]);
if (entries->empty())
- throw NothingMatching(spec);
+ nothing_matching_error(env.get(), *cmdline.begin_parameters(), filter::InstalledAtRoot(env->root()));
const std::shared_ptr<const PackageID> id(*entries->last());
if (! id->contents_key())
diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc
index de9ae4d..3114932 100644
--- a/src/clients/cave/cmd_info.cc
+++ b/src/clients/cave/cmd_info.cc
@@ -368,7 +368,7 @@ namespace
spec, { }) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]);
if (installed_ids->empty() && installable_ids->empty())
- throw NothingMatching(param);
+ nothing_matching_error(env.get(), param, filter::InstalledAtRoot(env->root()));
for (PackageIDSequence::ConstIterator i(installed_ids->begin()), i_end(installed_ids->end()) ;
i != i_end ; ++i)
diff --git a/src/clients/cave/cmd_perform.cc b/src/clients/cave/cmd_perform.cc
index 16f8d0c..89b3d12 100644
--- a/src/clients/cave/cmd_perform.cc
+++ b/src/clients/cave/cmd_perform.cc
@@ -402,12 +402,11 @@ PerformCommand::run(
std::string action(*cmdline.begin_parameters());
- PackageDepSpec spec(parse_user_package_dep_spec(*next(cmdline.begin_parameters()), env.get(),
- { }));
- const std::shared_ptr<const PackageIDSequence> ids((*env)[selection::AllVersionsUnsorted(
- generator::Matches(spec, { }))]);
+ const auto spec_str(*next(cmdline.begin_parameters()));
+ const auto spec(parse_user_package_dep_spec(spec_str, env.get(), { }));
+ const auto ids((*env)[selection::AllVersionsUnsorted(generator::Matches(spec, { }))]);
if (ids->empty())
- throw NothingMatching(spec);
+ nothing_matching_error(env.get(), spec_str, filter::All());
else if (1 != std::distance(ids->begin(), ids->end()))
throw BeMoreSpecific(spec, ids);
const std::shared_ptr<const PackageID> id(*ids->begin());
@@ -527,10 +526,9 @@ PerformCommand::run(
p != p_end ; ++p)
{
PackageDepSpec rspec(parse_user_package_dep_spec(*p, env.get(), { }));
- const std::shared_ptr<const PackageIDSequence> rids((*env)[selection::AllVersionsUnsorted(
- generator::Matches(rspec, { }))]);
+ const std::shared_ptr<const PackageIDSequence> rids((*env)[selection::AllVersionsUnsorted(generator::Matches(rspec, { }))]);
if (rids->empty())
- throw NothingMatching(rspec);
+ nothing_matching_error(env.get(), *p, filter::All());
else if (1 != std::distance(rids->begin(), rids->end()))
throw BeMoreSpecific(rspec, rids);
else
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 6b3df50..f3bfd67 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -1080,7 +1080,7 @@ ShowCommand::run(
}
}
- throw NothingMatching(*p);
+ nothing_matching_error(env.get(), *p, filter::All());
}
else
throw args::DoHelp("bad value '" + cmdline.a_type.argument() + "' for --" + cmdline.a_type.long_name());
diff --git a/src/clients/cave/cmd_uninstall.cc b/src/clients/cave/cmd_uninstall.cc
index 72e19f3..17626a2 100644
--- a/src/clients/cave/cmd_uninstall.cc
+++ b/src/clients/cave/cmd_uninstall.cc
@@ -142,7 +142,7 @@ UninstallCommand::run(
const std::shared_ptr<const PackageIDSequence> ids((*env)[selection::AllVersionsSorted(
generator::Matches(spec, { }) | filter::SupportsAction<UninstallAction>())]);
if (ids->empty())
- throw NothingMatching(spec);
+ nothing_matching_error(env.get(), *p, filter::SupportsAction<UninstallAction>());
else if ((! cmdline.a_all_versions.specified()) && has_multiple_versions(ids))
throw BeMoreSpecific(spec, ids);
else
diff --git a/src/clients/cave/cmd_verify.cc b/src/clients/cave/cmd_verify.cc
index ff338b3..b808165 100644
--- a/src/clients/cave/cmd_verify.cc
+++ b/src/clients/cave/cmd_verify.cc
@@ -209,7 +209,7 @@ VerifyCommand::run(
(*env)[selection::AllVersionsSorted(generator::Matches(spec, { }) | filter::InstalledAtRoot(env->root()))]);
if (entries->empty())
- throw NothingMatching(spec);
+ nothing_matching_error(env.get(), *cmdline.begin_parameters(), filter::InstalledAtRoot(env->root()));
int exit_status(0);
for (PackageIDSequence::ConstIterator i(entries->begin()), i_end(entries->end()) ;
diff --git a/src/clients/cave/exceptions.cc b/src/clients/cave/exceptions.cc
index fdb587a..f5c1e48 100644
--- a/src/clients/cave/exceptions.cc
+++ b/src/clients/cave/exceptions.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -56,3 +56,12 @@ BadRepositoryForCommand::BadRepositoryForCommand(const RepositoryName & name, co
{
}
+void
+paludis::cave::nothing_matching_error(
+ const Environment * const,
+ const std::string & s,
+ const Filter &)
+{
+ throw NothingMatching(s);
+}
+
diff --git a/src/clients/cave/exceptions.hh b/src/clients/cave/exceptions.hh
index 7621d05..9f6ad27 100644
--- a/src/clients/cave/exceptions.hh
+++ b/src/clients/cave/exceptions.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -24,6 +24,8 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/name-fwd.hh>
+#include <paludis/filter-fwd.hh>
+#include <paludis/environment-fwd.hh>
#include <memory>
namespace paludis
@@ -63,6 +65,11 @@ namespace paludis
const RepositoryName &,
const std::string & r) throw ();
};
+
+ void nothing_matching_error(
+ const Environment * const,
+ const std::string &,
+ const Filter &) PALUDIS_ATTRIBUTE((noreturn));
}
}