aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-21 17:00:58 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-20 22:05:46 +0000
commit6586b6cc8f63cb7fc32ee9bef0e98ad8822d87fd (patch)
tree5abfc9664ec9a1559bf12ecf6b60a31917a22ee8
parent1b3b5460ecfcdfb978251b4f84153e12eac0f715 (diff)
downloadpaludis-6586b6cc8f63cb7fc32ee9bef0e98ad8822d87fd.tar.gz
paludis-6586b6cc8f63cb7fc32ee9bef0e98ad8822d87fd.tar.xz
Show choices
-rw-r--r--src/clients/cave/cmd_show.cc59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 47c8f52..04f08b4 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 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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
@@ -43,6 +43,7 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/action.hh>
#include <paludis/mask.hh>
+#include <paludis/choice.hh>
#include <cstdlib>
#include <iostream>
#include <algorithm>
@@ -432,8 +433,62 @@ namespace
}
}
- void visit(const MetadataValueKey<std::tr1::shared_ptr<const Choices> > &)
+ void visit(const MetadataValueKey<std::tr1::shared_ptr<const Choices> > & k)
{
+ if (cmdline.a_flat.specified())
+ {
+ std::stringstream s;
+ bool empty_prefix(true);
+ for (Choices::ConstIterator c(k.value()->begin()), c_end(k.value()->end()) ;
+ c != c_end ; ++c)
+ {
+ if (! cmdline.a_internal_keys.specified())
+ {
+ if ((*c)->hidden())
+ continue;
+ if ((*c)->begin() == (*c)->end())
+ continue;
+ }
+
+ if ((! empty_prefix) || (! (*c)->show_with_no_prefix()))
+ {
+ s << (*c)->prefix() << ": ";
+ empty_prefix = false;
+ }
+
+ for (Choice::ConstIterator v((*c)->begin()), v_end((*c)->end()) ;
+ v != v_end ; ++v)
+ s << (*v)->unprefixed_name() << " ";
+ }
+ cout << format_general_rhvib(f::show_metadata_key_value(), k.raw_name(), k.human_name(),
+ s.str(), indent, important);
+ }
+ else
+ {
+ cout << format_general_rhvib(f::show_metadata_key_value(), k.raw_name(), k.human_name(),
+ "", indent, important);
+ for (Choices::ConstIterator c(k.value()->begin()), c_end(k.value()->end()) ;
+ c != c_end ; ++c)
+ {
+ if (! cmdline.a_internal_keys.specified())
+ {
+ if ((*c)->hidden())
+ continue;
+ if ((*c)->begin() == (*c)->end())
+ continue;
+ }
+
+ cout << format_general_rhvib(f::show_metadata_key_value(), (*c)->raw_name(), (*c)->human_name(),
+ "", indent + 1, important);
+
+ for (Choice::ConstIterator v((*c)->begin()), v_end((*c)->end()) ;
+ v != v_end ; ++v)
+ {
+ cout << format_general_rhvib(f::show_metadata_key_value(), stringify((*v)->name_with_prefix()),
+ stringify((*v)->unprefixed_name()), (*v)->description(), indent + 2, important);
+ }
+ }
+ }
}
void visit(const MetadataValueKey<std::tr1::shared_ptr<const RepositoryMaskInfo> > & k)