diff options
author | 2010-08-17 12:40:50 +0100 | |
---|---|---|
committer | 2010-08-17 12:40:50 +0100 | |
commit | 930c799a1cc6bb6c33ce1b5fe029f2c4848d69b0 (patch) | |
tree | a81a933961b4fe9ea2fb4669cec5ff8ce7e86157 | |
parent | b16723cdaaac3e6e8771c52f356c6bc0781e2ae7 (diff) | |
download | paludis-930c799a1cc6bb6c33ce1b5fe029f2c4848d69b0.tar.gz paludis-930c799a1cc6bb6c33ce1b5fe029f2c4848d69b0.tar.xz |
fmt show contents
-rw-r--r-- | src/clients/cave/cmd_print_formats.cc | 18 | ||||
-rw-r--r-- | src/clients/cave/cmd_show-fmt.hh | 13 | ||||
-rw-r--r-- | src/clients/cave/cmd_show.cc | 13 | ||||
-rw-r--r-- | src/clients/cave/format_user_config.hh | 34 |
4 files changed, 70 insertions, 8 deletions
diff --git a/src/clients/cave/cmd_print_formats.cc b/src/clients/cave/cmd_print_formats.cc index 8413a1138..45833236c 100644 --- a/src/clients/cave/cmd_print_formats.cc +++ b/src/clients/cave/cmd_print_formats.cc @@ -71,6 +71,24 @@ namespace return "%" + std::string(1, c_); } + template <char c_> + std::string param_if() + { + return "%{if " + std::string(1, c_) + "}"; + } + + template <char c_> + std::string param_else() + { + return "%{else}"; + } + + template <char c_> + std::string param_endif() + { + return "%{endif}"; + } + struct Storer { std::string user_key; diff --git a/src/clients/cave/cmd_show-fmt.hh b/src/clients/cave/cmd_show-fmt.hh index 67ab44ab6..edb9820f5 100644 --- a/src/clients/cave/cmd_show-fmt.hh +++ b/src/clients/cave/cmd_show-fmt.hh @@ -30,3 +30,16 @@ const auto fs_set_spec_installable = make_format_string_fetcher("show/set_spec_i const auto fs_set_spec_unavailable = make_format_string_fetcher("show/set_spec_unavailable", 1) << param<'i'>() << param<'i'>() << param<'i'>() << param<'i'>() << c::bold_red() << param<'s'>() << c::normal() << "\\n"; +const auto fs_contents_file = make_format_string_fetcher("show/contents_file", 1) + << param_if<'b'>() << "%{column 30}" << param_endif<'b'>() << param<'r'>() << param_if<'b'>() << "\\n" << param_else<'b'>() << " " << param_endif<'b'>(); + +const auto fs_contents_other = make_format_string_fetcher("show/contents_other", 1) + << param_if<'b'>() << "%{column 30}" << param_endif<'b'>() << param<'r'>() << param_if<'b'>() << "\\n" << param_else<'b'>() << " " << param_endif<'b'>(); + +const auto fs_contents_dir = make_format_string_fetcher("show/contents_dir", 1) + << param_if<'b'>() << "%{column 30}" << param_endif<'b'>() << param<'r'>() << param_if<'b'>() << "\\n" << param_else<'b'>() << " " << param_endif<'b'>(); + +const auto fs_contents_sym = make_format_string_fetcher("show/contents_sym", 1) + << param_if<'b'>() << "%{column 30}" << param_endif<'b'>() << param<'r'>() << " -> " << param<'v'>() + << param_if<'b'>() << "\\n" << param_else<'b'>() << " " << param_endif<'b'>(); + diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index 9c37c2f7f..54cbeae2d 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -254,26 +254,23 @@ namespace void visit(const ContentsFileEntry & e) { - s << format_general_rhvib(f::show_contents_file(), stringify(e.location_key()->value()), e.location_key()->value().basename(), - "", indent, indent); + s << fuc(fs_contents_file(), fv<'r'>(stringify(e.location_key()->value())), fv<'b'>(indent ? "true" : "")); } void visit(const ContentsDirEntry & e) { - s << format_general_rhvib(f::show_contents_dir(), stringify(e.location_key()->value()), e.location_key()->value().basename(), - "", indent, indent); + s << fuc(fs_contents_dir(), fv<'r'>(stringify(e.location_key()->value())), fv<'b'>(indent ? "true" : "")); } void visit(const ContentsSymEntry & e) { - s << format_general_rhvib(f::show_contents_sym(), stringify(e.location_key()->value()), e.location_key()->value().basename(), - e.target_key()->value(), indent, indent); + s << fuc(fs_contents_sym(), fv<'r'>(stringify(e.location_key()->value())), fv<'b'>(indent ? "true" : ""), + fv<'v'>(e.target_key()->value())); } void visit(const ContentsOtherEntry & e) { - s << format_general_rhvib(f::show_contents_other(), stringify(e.location_key()->value()), e.location_key()->value().basename(), - "", indent, indent); + s << fuc(fs_contents_other(), fv<'r'>(stringify(e.location_key()->value())), fv<'b'>(indent ? "true" : "")); } }; diff --git a/src/clients/cave/format_user_config.hh b/src/clients/cave/format_user_config.hh index 9faaed87b..bf2bf93df 100644 --- a/src/clients/cave/format_user_config.hh +++ b/src/clients/cave/format_user_config.hh @@ -315,6 +315,30 @@ namespace paludis return FormatParam<c_>(); } + template <char c_> + struct FormatParamIf + { + std::string text; + }; + + template <char c_> + FormatParamIf<c_> param_if() + { + return FormatParamIf<c_>{"%{if " + std::string(1, c_) + "}"}; + } + + template <char c_> + FormatParamIf<c_> param_else() + { + return FormatParamIf<c_>{"%{else}"}; + } + + template <char c_> + FormatParamIf<c_> param_endif() + { + return FormatParamIf<c_>{"%{endif}"}; + } + template <char... cs_> MakeFormatStringFetcher<cs_...> operator<< (MakeFormatStringFetcher<cs_...> && f, const std::string & s) { @@ -333,6 +357,16 @@ namespace paludis result.text.append(1, c_); return result; } + + template <char c_, char... cs_> + typename MakeDeduplicatedMakeFormatStringFetcher<c_, cs_...>::Type + operator<< (MakeFormatStringFetcher<cs_...> && f, const FormatParamIf<c_> & c) + { + typename MakeDeduplicatedMakeFormatStringFetcher<c_, cs_...>::Type result{ + std::move(f.user_key), f.user_key_version, std::move(f.text)}; + result.text.append(c.text); + return result; + } } extern template class Singleton<cave::FormatUserConfigFile>; |