diff options
author | Gennadiy Rozental <rogeeff@google.com> | 2023-04-06 11:43:21 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-04-06 11:44:07 -0700 |
commit | e73b9139ee9b853a4bd7812531442c138da09084 (patch) | |
tree | fad9785e725902bdffe39cf5bb1359f7b0bea8fe /absl/flags/parse.cc | |
parent | 0bc6509b8a7555b45e62946b31d8d39b8e142ae1 (diff) |
Use stdout for help output even in case of errors.
PiperOrigin-RevId: 522393331
Change-Id: Ia5f4ad6a2d16c033ea97f3c7e27e8eb7ee429242
Diffstat (limited to 'absl/flags/parse.cc')
-rw-r--r-- | absl/flags/parse.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc index d3609c13..172fe901 100644 --- a/absl/flags/parse.cc +++ b/absl/flags/parse.cc @@ -22,6 +22,7 @@ #include <cstdlib> #include <fstream> #include <iostream> +#include <ostream> #include <string> #include <tuple> #include <utility> @@ -693,7 +694,8 @@ std::vector<std::string> GetMisspellingHints(const absl::string_view flag) { std::vector<char*> ParseCommandLineImpl(int argc, char* argv[], UsageFlagsAction usage_flag_action, - OnUndefinedFlag undef_flag_action) { + OnUndefinedFlag undef_flag_action, + std::ostream& error_help_output) { std::vector<char*> positional_args; std::vector<UnrecognizedFlag> unrecognized_flags; @@ -707,8 +709,8 @@ std::vector<char*> ParseCommandLineImpl(int argc, char* argv[], if (undef_flag_action == OnUndefinedFlag::kAbortIfUndefined) { if (!unrecognized_flags.empty()) { - flags_internal::HandleUsageFlags(std::cerr, ProgramUsageMessage()); - std::exit(1); + flags_internal::HandleUsageFlags(error_help_output, + ProgramUsageMessage()); std::exit(1); } } } |