diff options
author | 2011-01-27 17:01:12 +0000 | |
---|---|---|
committer | 2011-01-27 17:01:12 +0000 | |
commit | c402dbcba1523b97ad8182e5ffa3211e993187a3 (patch) | |
tree | b319a178f57c0bce7228dfd30c5855702b629c08 | |
parent | 36b75ed1f5b48cb9ed9bc81024ca74e9641856eb (diff) | |
download | paludis-c402dbcba1523b97ad8182e5ffa3211e993187a3.tar.gz paludis-c402dbcba1523b97ad8182e5ffa3211e993187a3.tar.xz |
show permitted choice parameter values
-rw-r--r-- | src/clients/cave/cmd_show-fmt.hh | 9 | ||||
-rw-r--r-- | src/clients/cave/cmd_show.cc | 43 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/clients/cave/cmd_show-fmt.hh b/src/clients/cave/cmd_show-fmt.hh index 7f273bc86..a3a6e7e29 100644 --- a/src/clients/cave/cmd_show-fmt.hh +++ b/src/clients/cave/cmd_show-fmt.hh @@ -58,6 +58,15 @@ const auto fs_choice_disabled = make_format_string_fetcher("show/choice_disabled const auto fs_choice_parameter = make_format_string_fetcher("show/choice_parameter", 1) << "=" << param<'v'>(); +const auto fs_permitted_choice_value_int = make_format_string_fetcher("show/permitted_choice_value_int", 1) + << "%{column 30}Should be an integer" << param_if<'r'>() << " " << param<'r'>() << param_endif<'r'>() << "\\n"; + +const auto fs_permitted_choice_value_enum_values = make_format_string_fetcher("show/permitted_choice_value_enum_values", 1) + << "%{column 30}Permitted values:" << "\\n"; + +const auto fs_permitted_choice_value_enum_value = make_format_string_fetcher("show/permitted_choice_value_enum_value", 1) + << "%{column 40}" << param<'v'>() << param_if<'d'>() << ": " << "%{column 55}" << param<'d'>() << param_endif<'d'>() << "\\n"; + const auto fs_metadata_value_raw = make_format_string_fetcher("show/metadata_value_raw", 2) << " " << param<'i'>() << param<'i'>() << param<'i'>() << param<'i'>() << param_if<'b'>() << c::bold_normal() << param_endif<'b'>() << param<'s'>() << c::normal() diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index e4cdfa8d2..9fcd48585 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -49,6 +49,7 @@ #include <paludis/choice.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/mask_utils.hh> +#include <paludis/permitted_choice_value_parameter_values.hh> #include <cstdlib> #include <iostream> #include <algorithm> @@ -342,6 +343,42 @@ namespace return ""; } + struct PermittedChoiceValueParameterValuesDisplayer + { + std::ostream & out; + + void visit(const PermittedChoiceValueParameterIntegerValue & v) const + { + std::string range; + + if (v.minimum_allowed_value() != std::numeric_limits<int>::min()) + { + if (v.maximum_allowed_value() != std::numeric_limits<int>::max()) + range = "between " + stringify(v.minimum_allowed_value()) + " and " + stringify(v.maximum_allowed_value()); + else + range = ">= " + stringify(v.minimum_allowed_value()); + } + else if (v.maximum_allowed_value() != std::numeric_limits<int>::max()) + range = "<= " + stringify(v.maximum_allowed_value()); + + out << fuc( + fs_permitted_choice_value_int(), + fv<'r'>(range) + ); + } + + void visit(const PermittedChoiceValueParameterEnumValue & v) const + { + if (! v.allowed_values_and_descriptions()->empty()) + { + out << fuc(fs_permitted_choice_value_enum_values()); + for (auto a(v.allowed_values_and_descriptions()->begin()), a_end(v.allowed_values_and_descriptions()->end()) ; + a != a_end ; ++a) + out << fuc(fs_permitted_choice_value_enum_value(), fv<'v'>(a->first), fv<'d'>(a->second)); + } + } + }; + struct InfoDisplayer { const std::shared_ptr<const Environment> env; @@ -925,6 +962,12 @@ namespace ); } } + + if ((*v)->permitted_parameter_values()) + { + PermittedChoiceValueParameterValuesDisplayer d{out}; + (*v)->permitted_parameter_values()->accept(d); + } } } } |