diff options
author | Benjamin Barenblat <bbaren@google.com> | 2023-09-07 13:16:09 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2023-09-07 13:16:09 -0400 |
commit | 6fdbff8bbce2a1debdc060df381f39e3dcfb65af (patch) | |
tree | 71f1ef38477a65d5cce472fc042c90087c2bb351 /absl/flags/internal/usage.h | |
parent | 8d4a80fe37176b1170d7dce0772dea9584ec3e32 (diff) | |
parent | 29bf8085f3bf17b84d30e34b3d7ff8248fda404e (diff) | |
download | abseil-6fdbff8bbce2a1debdc060df381f39e3dcfb65af.tar.gz abseil-6fdbff8bbce2a1debdc060df381f39e3dcfb65af.tar.bz2 abseil-6fdbff8bbce2a1debdc060df381f39e3dcfb65af.zip |
Merge new upstream LTS 20230802.0
Diffstat (limited to 'absl/flags/internal/usage.h')
-rw-r--r-- | absl/flags/internal/usage.h | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/absl/flags/internal/usage.h b/absl/flags/internal/usage.h index c0bcac57..a96cbf38 100644 --- a/absl/flags/internal/usage.h +++ b/absl/flags/internal/usage.h @@ -17,11 +17,11 @@ #define ABSL_FLAGS_INTERNAL_USAGE_H_ #include <iosfwd> +#include <ostream> #include <string> #include "absl/base/config.h" #include "absl/flags/commandlineflag.h" -#include "absl/flags/declare.h" #include "absl/strings/string_view.h" // -------------------------------------------------------------------- @@ -36,6 +36,18 @@ enum class HelpFormat { kHumanReadable, }; +// The kind of usage help requested. +enum class HelpMode { + kNone, + kImportant, + kShort, + kFull, + kPackage, + kMatch, + kVersion, + kOnlyCheckArgs +}; + // Streams the help message describing `flag` to `out`. // The default value for `flag` is included in the output. void FlagHelp(std::ostream& out, const CommandLineFlag& flag, @@ -57,28 +69,18 @@ void FlagsHelp(std::ostream& out, absl::string_view filter, // If any of the 'usage' related command line flags (listed on the bottom of // this file) has been set this routine produces corresponding help message in -// the specified output stream and returns: -// 0 - if "version" or "only_check_flags" flags were set and handled. -// 1 - if some other 'usage' related flag was set and handled. -// -1 - if no usage flags were set on a commmand line. -// Non negative return values are expected to be used as an exit code for a -// binary. -int HandleUsageFlags(std::ostream& out, - absl::string_view program_usage_message); +// the specified output stream and returns HelpMode that was handled. Otherwise +// it returns HelpMode::kNone. +HelpMode HandleUsageFlags(std::ostream& out, + absl::string_view program_usage_message); // -------------------------------------------------------------------- -// Globals representing usage reporting flags +// Encapsulates the logic of exiting the binary depending on handled help mode. -enum class HelpMode { - kNone, - kImportant, - kShort, - kFull, - kPackage, - kMatch, - kVersion, - kOnlyCheckArgs -}; +void MaybeExit(HelpMode mode); + +// -------------------------------------------------------------------- +// Globals representing usage reporting flags // Returns substring to filter help output (--help=substr argument) std::string GetFlagsHelpMatchSubstr(); |