diff options
Diffstat (limited to 'absl/flags/internal/usage.cc')
-rw-r--r-- | absl/flags/internal/usage.cc | 17 |
1 files changed, 13 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); + } } // -------------------------------------------------------------------- |