aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-12 22:21:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-14 20:42:42 +0000
commit3519c80ab34b22e404e516bde02471226aa6c36e (patch)
treed21d7ddb95f5358aac786f237988bed5cd826f9e
parent0d6e4d15661335ae026a3c7ef58db0f0c61e3884 (diff)
downloadpaludis-3519c80ab34b22e404e516bde02471226aa6c36e.tar.gz
paludis-3519c80ab34b22e404e516bde02471226aa6c36e.tar.xz
'cave show' set contents recursively
-rw-r--r--src/clients/cave/cmd_show.cc30
-rw-r--r--src/clients/cave/format_general.cc11
-rw-r--r--src/clients/cave/format_general.hh5
-rw-r--r--src/clients/cave/formats.cc8
4 files changed, 41 insertions, 13 deletions
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 913b543..bee572e 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 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
@@ -129,24 +129,40 @@ namespace
struct SetDisplayer
{
const std::tr1::shared_ptr<const Environment> env;
+ int indent;
+ std::set<SetName> recursing_sets;
- SetDisplayer(const std::tr1::shared_ptr<const Environment> & e) :
- env(e)
+ SetDisplayer(const std::tr1::shared_ptr<const Environment> & e, const int i) :
+ env(e),
+ indent(i)
{
}
void visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node)
{
- cout << format_general_s(select_format_for_spec(env, *node.spec(),
+ cout << format_general_si(select_format_for_spec(env, *node.spec(),
f::show_set_spec_installed(),
f::show_set_spec_installable(),
f::show_set_spec_unavailable()),
- stringify(*node.spec()));
+ stringify(*node.spec()), indent);
}
void visit(const SetSpecTree::NodeType<NamedSetDepSpec>::Type & node)
{
- cout << format_general_s(f::show_set_set(), stringify(*node.spec()));
+ cout << format_general_si(f::show_set_set(), stringify(*node.spec()), indent);
+
+ const std::tr1::shared_ptr<const SetSpecTree> set(env->set(node.spec()->name()));
+ if (! set)
+ throw NoSuchSetError(stringify(node.spec()->name()));
+
+ if (! recursing_sets.insert(node.spec()->name()).second)
+ throw RecursivelyDefinedSetError(stringify(node.spec()->name()));
+ ++indent;
+
+ set->root()->accept(*this);
+
+ recursing_sets.erase(node.spec()->name());
+ --indent;
}
void visit(const SetSpecTree::NodeType<AllDepSpec>::Type & node)
@@ -163,7 +179,7 @@ namespace
if (! set)
throw NoSuchSetError(stringify(s));
- SetDisplayer d(env);
+ SetDisplayer d(env, 1);
set->root()->accept(d);
cout << endl;
diff --git a/src/clients/cave/format_general.cc b/src/clients/cave/format_general.cc
index d93c6bf..d8c22a0 100644
--- a/src/clients/cave/format_general.cc
+++ b/src/clients/cave/format_general.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
@@ -34,6 +34,15 @@ paludis::cave::format_general_s(const std::string & f, const std::string & s)
}
std::string
+paludis::cave::format_general_si(const std::string & f, const std::string & s, const int i)
+{
+ std::tr1::shared_ptr<Map<char, std::string> > m(new Map<char, std::string>);
+ m->insert('s', s);
+ m->insert('i', std::string(i, ' '));
+ return format_string(f, m);
+}
+
+std::string
paludis::cave::format_general_kv(const std::string & f, const std::string & k, const std::string & v)
{
std::tr1::shared_ptr<Map<char, std::string> > m(new Map<char, std::string>);
diff --git a/src/clients/cave/format_general.hh b/src/clients/cave/format_general.hh
index 7b7f6f5..d7e8a83 100644
--- a/src/clients/cave/format_general.hh
+++ b/src/clients/cave/format_general.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
@@ -30,6 +30,9 @@ namespace paludis
std::string format_general_s(const std::string & f, const std::string & s)
PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+ std::string format_general_si(const std::string & f, const std::string & s, const int i)
+ PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+
std::string format_general_sr(const std::string & f, const std::string & s, const std::string & r)
PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index 45e0191..2f32fa5 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -91,25 +91,25 @@ paludis::cave::f::show_set_heading()
const std::string
paludis::cave::f::show_set_set()
{
- return " " + c::blue() + "%s" + c::normal() + "\\n";
+ return "%i%i%i%i" + c::blue() + "%s" + c::normal() + "\\n";
}
const std::string
paludis::cave::f::show_set_spec_installed()
{
- return " " + c::bold_green() + "%s" + c::normal() + "\\n";
+ return "%i%i%i%i" + c::bold_green() + "%s" + c::normal() + "\\n";
}
const std::string
paludis::cave::f::show_set_spec_installable()
{
- return " " + c::green() + "%s" + c::normal() + "\\n";
+ return "%i%i%i%i" + c::green() + "%s" + c::normal() + "\\n";
}
const std::string
paludis::cave::f::show_set_spec_unavailable()
{
- return " " + c::red() + "%s" + c::normal() + "\\n";
+ return "%i%i%i%i" + c::red() + "%s" + c::normal() + "\\n";
}
const std::string