diff options
Diffstat (limited to 'absl/flags')
-rw-r--r-- | absl/flags/internal/usage.cc | 17 | ||||
-rw-r--r-- | absl/flags/internal/usage_test.cc | 3 |
2 files changed, 16 insertions, 4 deletions
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc index 949709e8..a883567f 100644 --- a/absl/flags/internal/usage.cc +++ b/absl/flags/internal/usage.cc @@ -17,6 +17,7 @@ #include <stdint.h> +#include <algorithm> #include <functional> #include <map> #include <ostream> @@ -255,9 +256,6 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb, matching_flags; flags_internal::ForEachFlag([&](absl::CommandLineFlag& flag) { - // Ignore retired flags. - if (flag.IsRetired()) return; - // If the flag has been stripped, pretend that it doesn't exist. if (flag.Help() == flags_internal::kStrippedFlagHelp) return; @@ -275,6 +273,14 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb, absl::string_view file_separator; // controls blank lines between files for (auto& package : matching_flags) { if (format == HelpFormat::kHumanReadable) { + // Hide packages with only retired flags + bool all_package_flags_are_retired = true; + for (const auto& flags_in_file : package.second) { + for (const auto* flag : flags_in_file.second) { + all_package_flags_are_retired &= flag->IsRetired(); + } + } + if (all_package_flags_are_retired) continue; out << package_separator; package_separator = "\n\n"; } @@ -334,8 +340,11 @@ void FlagsHelpImpl(std::ostream& out, // Produces the help message describing specific flag. void FlagHelp(std::ostream& out, const CommandLineFlag& flag, HelpFormat format) { - if (format == HelpFormat::kHumanReadable) + if (format == HelpFormat::kHumanReadable) { + // Ignore retired flags + if (flag.IsRetired()) return; flags_internal::FlagHelpHumanReadable(flag, out); + } } // -------------------------------------------------------------------- diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc index 044d71c8..5055640a 100644 --- a/absl/flags/internal/usage_test.cc +++ b/absl/flags/internal/usage_test.cc @@ -61,6 +61,9 @@ ABSL_FLAG( "Even more long long long long long long long long long long long long " "help message."); +ABSL_RETIRED_FLAG(int64_t, usage_reporting_test_flag_07, 1, + "usage_reporting_test_flag_07 help message"); + namespace { namespace flags = absl::flags_internal; |