aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-17 10:27:11 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-17 10:39:19 +0100
commit40d21dc768b9af290a4ee3a4d91d9b1245a4b549 (patch)
tree82c43b791c978bf1b29c5b25de618003d45d53ad
parente0905495c3b27b78afb163a0d3e6507366b15b96 (diff)
downloadpaludis-40d21dc768b9af290a4ee3a4d91d9b1245a4b549.tar.gz
paludis-40d21dc768b9af290a4ee3a4d91d9b1245a4b549.tar.xz
fmt info
-rw-r--r--src/clients/cave/Makefile.am2
-rw-r--r--src/clients/cave/cmd_info-fmt.hh17
-rw-r--r--src/clients/cave/cmd_info.cc54
-rw-r--r--src/clients/cave/cmd_print_formats.cc2
-rw-r--r--src/clients/cave/formats.cc30
-rw-r--r--src/clients/cave/formats.hh6
6 files changed, 48 insertions, 63 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index e846e03..0d3ac6e 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -121,7 +121,7 @@ libcave_a_SOURCES = \
cmd_fix_linkage.cc cmd_fix_linkage.hh \
cmd_help.cc cmd_help.hh \
cmd_import.cc cmd_import.hh \
- cmd_info.cc cmd_info.hh \
+ cmd_info.cc cmd_info.hh cmd_info-fmt.hh \
cmd_manage_search_index.cc cmd_manage_search_index.hh \
cmd_match.cc cmd_match.hh \
cmd_owner.cc cmd_owner.hh cmd_owner-fmt.hh \
diff --git a/src/clients/cave/cmd_info-fmt.hh b/src/clients/cave/cmd_info-fmt.hh
new file mode 100644
index 0000000..919c93e
--- /dev/null
+++ b/src/clients/cave/cmd_info-fmt.hh
@@ -0,0 +1,17 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+const auto fs_metadata = make_format_string_fetcher("info/metadata", 1)
+ << param<'i'>() << param<'i'>() << param<'i'>() << param<'i'>() << param<'h'>() << "%{column 30}" << param<'s'>() << "\\n";
+
+const auto fs_metadata_subsection = make_format_string_fetcher("info/metadata_subsection", 1)
+ << param<'i'>() << param<'i'>() << param<'i'>() << param<'i'>() << param<'s'>() << "\\n";
+
+const auto fs_repository_heading = make_format_string_fetcher("info/repository_heading", 1)
+ << "Repository " << c::blue_or_pink() << param<'s'>() << c::normal() << ":\\n";
+
+const auto fs_id_heading = make_format_string_fetcher("info/id_heading", 1)
+ << "Extra Information for " << c::blue_or_pink() << param<'s'>() << c::normal() << ":\\n";
+
+const auto fs_heading = make_format_string_fetcher("info/heading", 1)
+ << c::blue_or_pink() << param<'s'>() << c::normal() << ":\\n";
+
diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc
index 2caab8e..3fda0e2 100644
--- a/src/clients/cave/cmd_info.cc
+++ b/src/clients/cave/cmd_info.cc
@@ -23,6 +23,8 @@
#include "format_general.hh"
#include "formats.hh"
#include "exceptions.hh"
+#include "format_user_config.hh"
+
#include <paludis/args/args.hh>
#include <paludis/args/do_help.hh>
#include <paludis/name.hh>
@@ -57,6 +59,8 @@ using std::endl;
namespace
{
+#include "cmd_info-fmt.hh"
+
struct InfoCommandLine :
CaveCommandCommandLine
{
@@ -145,7 +149,7 @@ namespace
void visit(const MetadataSectionKey & k)
{
- cout << format_general_his(f::info_metadata_subsection(), k.human_name(), indent, k.human_name());
+ cout << fuc(fs_metadata_subsection(), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.human_name()));
std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(k.begin_metadata(), k.end_metadata());
for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
s(keys.begin()), s_end(keys.end()) ; s != s_end ; ++s)
@@ -158,104 +162,103 @@ namespace
void visit(const MetadataCollectionKey<KeywordNameSet> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataCollectionKey<Set<std::string> > & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataCollectionKey<Sequence<std::string> > & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataCollectionKey<PackageIDSequence> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataCollectionKey<FSEntrySequence> & k)
{
- ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent,
- join(k.value()->begin(), k.value()->end(), " "));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(
+ join(k.value()->begin(), k.value()->end(), " ")));
}
void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataSpecTreeKey<SimpleURISpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataSpecTreeKey<PlainTextSpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataSpecTreeKey<FetchableURISpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, k.pretty_print_flat(f));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.pretty_print_flat(f)));
}
void visit(const MetadataValueKey<std::string> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(k.value())));
}
void visit(const MetadataValueKey<SlotName> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(k.value())));
}
void visit(const MetadataValueKey<long> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(k.value())));
}
void visit(const MetadataValueKey<bool> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(k.value())));
}
void visit(const MetadataValueKey<FSEntry> & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(k.value())));
}
void visit(const MetadataValueKey<std::shared_ptr<const PackageID> > & k)
{
ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, stringify(*k.value()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(stringify(*k.value())));
}
void visit(const MetadataValueKey<std::shared_ptr<const Contents> > &)
@@ -272,8 +275,7 @@ namespace
void visit(const MetadataTimeKey & k)
{
- ColourFormatter f(indent);
- cout << format_general_his(f::info_metadata(), k.human_name(), indent, pretty_print_time(k.value().seconds()));
+ cout << fuc(fs_metadata(), fv<'h'>(k.human_name()), fv<'i'>(std::string(indent, ' ')), fv<'s'>(pretty_print_time(k.value().seconds())));
}
};
@@ -282,7 +284,7 @@ namespace
const std::shared_ptr<Environment> &,
const std::shared_ptr<const Repository> & repo)
{
- cout << format_general_s(f::info_repository_heading(), stringify(repo->name()));
+ cout << fuc(fs_repository_heading(), fv<'s'>(stringify(repo->name())));
std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(repo->begin_metadata(), repo->end_metadata());
for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k)
@@ -300,7 +302,7 @@ namespace
const InfoCommandLine & cmdline,
const std::shared_ptr<Environment> & env)
{
- cout << format_general_s(f::info_heading(), "Environment Information");
+ cout << fuc(fs_heading(), fv<'s'>("Environment Information"));
std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(env->begin_metadata(), env->end_metadata());
for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k)
@@ -318,7 +320,7 @@ namespace
const InfoCommandLine & cmdline,
const std::shared_ptr<Environment> &)
{
- cout << format_general_s(f::info_heading(), "Package Manager Information");
+ cout << fuc(fs_heading(), fv<'s'>("Package Manager Information"));
std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(AboutMetadata::get_instance()->begin_metadata(),
AboutMetadata::get_instance()->end_metadata());
for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
@@ -341,7 +343,7 @@ namespace
if (! id->supports_action(SupportsActionTest<InfoAction>()))
return;
- cout << format_general_s(f::info_id_heading(), stringify(*id));
+ cout << fuc(fs_id_heading(), fv<'s'>(stringify(*id)));
std::shared_ptr<Sequence<std::string> > args(std::make_shared<Sequence<std::string>>());
args->push_back("info");
diff --git a/src/clients/cave/cmd_print_formats.cc b/src/clients/cave/cmd_print_formats.cc
index 75c2cf7..7391c32 100644
--- a/src/clients/cave/cmd_print_formats.cc
+++ b/src/clients/cave/cmd_print_formats.cc
@@ -108,6 +108,8 @@ namespace
}{
#include "cmd_fix_cache-fmt.hh"
}{
+#include "cmd_info-fmt.hh"
+ }{
#include "cmd_owner-fmt.hh"
}{
#include "cmd_report-fmt.hh"
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index b1cc979..19dad56 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -293,36 +293,6 @@ paludis::cave::f::show_package_id_masks_overridden()
}
const std::string
-paludis::cave::f::info_metadata()
-{
- return "%i%i%i%i%h%{column 30}%s\\n";
-}
-
-const std::string
-paludis::cave::f::info_metadata_subsection()
-{
- return "%i%i%i%i" + c::blue_or_pink() + "%s" + c::normal() + ":\\n";
-}
-
-const std::string
-paludis::cave::f::info_repository_heading()
-{
- return "Repository " + c::blue_or_pink() + "%s" + c::normal() + ":\\n";
-}
-
-const std::string
-paludis::cave::f::info_id_heading()
-{
- return "Extra Information for " + c::blue_or_pink() + "%s" + c::normal() + ":\\n";
-}
-
-const std::string
-paludis::cave::f::info_heading()
-{
- return c::blue_or_pink() + "%s" + c::normal() + ":\\n";
-}
-
-const std::string
paludis::cave::f::colour_formatter_keyword_name_plain()
{
return "%s";
diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh
index ea6db33..f79dccf 100644
--- a/src/clients/cave/formats.hh
+++ b/src/clients/cave/formats.hh
@@ -92,12 +92,6 @@ namespace paludis
const std::string show_choice_forced_disabled();
const std::string show_choice_disabled();
- 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();
const std::string colour_formatter_keyword_name_accepted();
const std::string colour_formatter_keyword_name_unaccepted();