aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-12 14:10:04 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-12 14:10:29 +0000
commitd1742f878e78e42aebe2f34b7e25912a3aaae18b (patch)
tree50cfa587a55f259bde907f1f2816eebc7b995b33
parent85b010012b482d640c7a117002c7b8a2b6dbbcb6 (diff)
downloadpaludis-d1742f878e78e42aebe2f34b7e25912a3aaae18b.tar.gz
paludis-d1742f878e78e42aebe2f34b7e25912a3aaae18b.tar.xz
cave info does ID things too
-rw-r--r--src/clients/cave/cmd_info.cc55
-rw-r--r--src/clients/cave/formats.cc6
-rw-r--r--src/clients/cave/formats.hh1
3 files changed, 59 insertions, 3 deletions
diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc
index 88190bc..63eac7f 100644
--- a/src/clients/cave/cmd_info.cc
+++ b/src/clients/cave/cmd_info.cc
@@ -18,11 +18,11 @@
*/
#include "cmd_info.hh"
+#include "cmd_perform.hh"
#include "colour_formatter.hh"
#include "format_general.hh"
#include "formats.hh"
#include "exceptions.hh"
-#include "select_format_for_spec.hh"
#include <paludis/args/args.hh>
#include <paludis/args/do_help.hh>
#include <paludis/name.hh>
@@ -333,6 +333,52 @@ namespace
}
cout << endl;
}
+
+ void do_one_id(
+ const InfoCommandLine &,
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (! id->supports_action(SupportsActionTest<InfoAction>()))
+ return;
+
+ cout << format_general_s(f::info_id_heading(), stringify(*id));
+
+ std::tr1::shared_ptr<Sequence<std::string> > args(new Sequence<std::string>);
+ args->push_back("info");
+ args->push_back("--if-supported");
+ args->push_back("--hooks");
+ args->push_back(stringify(id->uniquely_identifying_spec()));
+
+ PerformCommand command;
+ command.run(env, args);
+
+ cout << endl;
+ }
+
+ void do_one_param(
+ const InfoCommandLine & cmdline,
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::string & param)
+ {
+ PackageDepSpec spec(parse_user_package_dep_spec(param, env.get(), UserPackageDepSpecOptions()));
+
+ const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*env)[selection::AllVersionsSorted(generator::Matches(
+ spec, MatchPackageOptions()) | filter::InstalledAtRoot(env->root()))]);
+ const std::tr1::shared_ptr<const PackageIDSequence> installable_ids((*env)[selection::BestVersionOnly(generator::Matches(
+ spec, MatchPackageOptions()) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]);
+
+ if (installed_ids->empty() && installable_ids->empty())
+ throw NothingMatching(param);
+
+ for (PackageIDSequence::ConstIterator i(installed_ids->begin()), i_end(installed_ids->end()) ;
+ i != i_end ; ++i)
+ do_one_id(cmdline, env, *i);
+
+ for (PackageIDSequence::ConstIterator i(installable_ids->begin()), i_end(installable_ids->end()) ;
+ i != i_end ; ++i)
+ do_one_id(cmdline, env, *i);
+ }
}
bool
@@ -366,13 +412,16 @@ InfoCommand::run(
if (cmdline.begin_parameters() == cmdline.end_parameters())
{
+ cout << c::bold_red() << "No packages were specified on the command line, so detailed information is not" << c::normal() << endl;
+ cout << c::bold_red() << "available. If you are using this information for a bug report, you should pass " << c::normal() << endl;
+ cout << c::bold_red() << "the relevant package names as parameters." << c::normal() << endl;
+ cout << endl;
}
else
{
for (InfoCommandLine::ParametersConstIterator p(cmdline.begin_parameters()), p_end(cmdline.end_parameters()) ;
p != p_end ; ++p)
- {
- }
+ do_one_param(cmdline, env, *p);
}
return EXIT_SUCCESS;
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index 75a15c7..ae6244d 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -245,6 +245,12 @@ paludis::cave::f::info_repository_heading()
}
const std::string
+paludis::cave::f::info_id_heading()
+{
+ return "Extra Information for " + c::blue() + "%s" + c::normal() + ":\\n";
+}
+
+const std::string
paludis::cave::f::info_heading()
{
return c::blue() + "%s" + c::normal() + ":\\n";
diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh
index e48f1ef..2444ab0 100644
--- a/src/clients/cave/formats.hh
+++ b/src/clients/cave/formats.hh
@@ -86,6 +86,7 @@ namespace paludis
const std::string info_metadata();
const std::string info_metadata_subsection();
const std::string info_repository_heading();
+ const std::string info_id_heading();
const std::string info_heading();
const std::string colour_formatter_keyword_name_plain();