diff options
author | 2010-08-17 11:47:30 +0100 | |
---|---|---|
committer | 2010-08-17 11:47:30 +0100 | |
commit | 78122dea7896e886dc221b008f8c7e6841431049 (patch) | |
tree | 7988fc72019931c8dbd83a841ab939432d42da1d | |
parent | bc22ef1797cb07135fd46f3e8f1289e9220e38cf (diff) | |
download | paludis-78122dea7896e886dc221b008f8c7e6841431049.tar.gz paludis-78122dea7896e886dc221b008f8c7e6841431049.tar.xz |
fmt show wildcard
-rw-r--r-- | src/clients/cave/cmd_show-fmt.hh | 12 | ||||
-rw-r--r-- | src/clients/cave/cmd_show.cc | 12 | ||||
-rw-r--r-- | src/clients/cave/formats.cc | 24 | ||||
-rw-r--r-- | src/clients/cave/formats.hh | 5 | ||||
-rw-r--r-- | src/clients/cave/select_format_for_spec.cc | 26 | ||||
-rw-r--r-- | src/clients/cave/select_format_for_spec.hh | 11 |
6 files changed, 46 insertions, 44 deletions
diff --git a/src/clients/cave/cmd_show-fmt.hh b/src/clients/cave/cmd_show-fmt.hh index fbd8da341..89ff33bcf 100644 --- a/src/clients/cave/cmd_show-fmt.hh +++ b/src/clients/cave/cmd_show-fmt.hh @@ -3,3 +3,15 @@ const auto fs_repository_heading = make_format_string_fetcher("show/repository_heading", 1) << "* " << c::bold_blue_or_pink() << param<'s'>() << c::normal() << "\\n"; +const auto fs_wildcard_heading = make_format_string_fetcher("show/wildcard_heading", 1) + << "* " << c::bold_blue_or_pink() << param<'s'>() << c::normal() << "\\n"; + +const auto fs_wildcard_spec_installed = make_format_string_fetcher("show/wildcard_spec_installed", 1) + << " " << c::green_or_pink() << param<'s'>() << c::normal() << "\\n"; + +const auto fs_wildcard_spec_installable = make_format_string_fetcher("show/wildcard_spec_installable", 1) + << " " << param<'s'>() << c::normal() << "\\n"; + +const auto fs_wildcard_spec_unavailable = make_format_string_fetcher("show/wildcard_spec_unavailable", 1) + << " " << c::red() << param<'s'>() << c::normal() << "\\n"; + diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index 16d6e625c..76ad18604 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -206,7 +206,7 @@ namespace void do_one_wildcard(const std::shared_ptr<Environment> & env, const PackageDepSpec & s) { - cout << format_general_s(f::show_wildcard_heading(), stringify(s)); + cout << fuc(fs_wildcard_heading(), fv<'s'>(stringify(s))); const std::shared_ptr<const PackageIDSequence> names((*env)[selection::BestVersionOnly(generator::Matches(s, { }))]); if (names->empty()) @@ -216,12 +216,12 @@ namespace i != i_end ; ++i) { PackageDepSpec name_spec(make_package_dep_spec({ }).package((*i)->name())); - cout << format_general_s(select_format_for_spec(env, name_spec, - f::show_wildcard_spec_installed(), - f::show_wildcard_spec_installable(), - f::show_wildcard_spec_unavailable() + cout << fuc(select_format_for_spec(env, name_spec, + fs_wildcard_spec_installed(), + fs_wildcard_spec_installable(), + fs_wildcard_spec_unavailable() ), - stringify(name_spec)); + fv<'s'>(stringify(name_spec))); } cout << endl; diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc index eb50ed07c..3e8f8f784 100644 --- a/src/clients/cave/formats.cc +++ b/src/clients/cave/formats.cc @@ -167,30 +167,6 @@ paludis::cave::f::show_set_spec_unavailable() } const std::string -paludis::cave::f::show_wildcard_heading() -{ - return "* " + c::bold_blue_or_pink() + "%s" + c::normal() + "\\n"; -} - -const std::string -paludis::cave::f::show_wildcard_spec_installed() -{ - return " " + c::green_or_pink() + "%s" + c::normal() + "\\n"; -} - -const std::string -paludis::cave::f::show_wildcard_spec_installable() -{ - return " %s\\n"; -} - -const std::string -paludis::cave::f::show_wildcard_spec_unavailable() -{ - return " " + c::red() + "%s" + c::normal() + "\\n"; -} - -const std::string paludis::cave::f::show_metadata_key_value_raw() { return " %i%i%i%i%{if b}" + c::bold_normal() + "%{endif}" + "%r" + c::normal() + "%{column 30}%v\\n"; diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh index b3fe520de..3323e203c 100644 --- a/src/clients/cave/formats.hh +++ b/src/clients/cave/formats.hh @@ -56,11 +56,6 @@ namespace paludis const std::string show_set_spec_installable(); const std::string show_set_spec_unavailable(); - const std::string show_wildcard_heading(); - const std::string show_wildcard_spec_installed(); - const std::string show_wildcard_spec_installable(); - const std::string show_wildcard_spec_unavailable(); - const std::string show_package_heading(); const std::string show_package_repository(); const std::string show_package_version_installed(); diff --git a/src/clients/cave/select_format_for_spec.cc b/src/clients/cave/select_format_for_spec.cc index d84422d75..c7df9ba76 100644 --- a/src/clients/cave/select_format_for_spec.cc +++ b/src/clients/cave/select_format_for_spec.cc @@ -18,6 +18,7 @@ */ #include "select_format_for_spec.hh" +#include "format_user_config.hh" #include <paludis/environment.hh> #include <paludis/util/sequence.hh> #include <paludis/util/fs_entry.hh> @@ -29,13 +30,14 @@ using namespace paludis; using namespace cave; -std::string +template <typename T_> +T_ paludis::cave::select_format_for_spec( const std::shared_ptr<const Environment> & env, const PackageDepSpec & spec, - const std::string & if_installed, - const std::string & if_installable, - const std::string & if_unavailable + const T_ & if_installed, + const T_ & if_installable, + const T_ & if_unavailable ) { if (! (*env)[selection::SomeArbitraryVersion(generator::Matches(spec, { }) | filter::InstalledAtRoot(FSEntry("/")))]->empty()) @@ -46,3 +48,19 @@ paludis::cave::select_format_for_spec( return if_unavailable; } +template std::string paludis::cave::select_format_for_spec( + const std::shared_ptr<const Environment> & env, + const PackageDepSpec & spec, + const std::string & if_installed, + const std::string & if_installable, + const std::string & if_unavailable + ); + +template FormatString<'s'> paludis::cave::select_format_for_spec( + const std::shared_ptr<const Environment> & env, + const PackageDepSpec & spec, + const FormatString<'s'> & if_installed, + const FormatString<'s'> & if_installable, + const FormatString<'s'> & if_unavailable + ); + diff --git a/src/clients/cave/select_format_for_spec.hh b/src/clients/cave/select_format_for_spec.hh index 53b7fa71e..a946e772d 100644 --- a/src/clients/cave/select_format_for_spec.hh +++ b/src/clients/cave/select_format_for_spec.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 @@ -29,12 +29,13 @@ namespace paludis { namespace cave { - std::string select_format_for_spec( + template <typename T_> + T_ select_format_for_spec( const std::shared_ptr<const Environment> &, const PackageDepSpec &, - const std::string & if_installed, - const std::string & if_installable, - const std::string & if_unavailable + const T_ & if_installed, + const T_ & if_installable, + const T_ & if_unavailable ) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result)); } } |