summaryrefslogtreecommitdiff
path: root/absl/flags/internal/parse.h
diff options
context:
space:
mode:
authorGravatar Gennadiy Rozental <rogeeff@google.com>2023-04-06 11:43:21 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-04-06 11:44:07 -0700
commite73b9139ee9b853a4bd7812531442c138da09084 (patch)
treefad9785e725902bdffe39cf5bb1359f7b0bea8fe /absl/flags/internal/parse.h
parent0bc6509b8a7555b45e62946b31d8d39b8e142ae1 (diff)
Use stdout for help output even in case of errors.
PiperOrigin-RevId: 522393331 Change-Id: Ia5f4ad6a2d16c033ea97f3c7e27e8eb7ee429242
Diffstat (limited to 'absl/flags/internal/parse.h')
-rw-r--r--absl/flags/internal/parse.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/absl/flags/internal/parse.h b/absl/flags/internal/parse.h
index e4352049..10c531b8 100644
--- a/absl/flags/internal/parse.h
+++ b/absl/flags/internal/parse.h
@@ -16,6 +16,8 @@
#ifndef ABSL_FLAGS_INTERNAL_PARSE_H_
#define ABSL_FLAGS_INTERNAL_PARSE_H_
+#include <iostream>
+#include <ostream>
#include <string>
#include <vector>
@@ -40,9 +42,15 @@ enum class OnUndefinedFlag {
kAbortIfUndefined
};
-std::vector<char*> ParseCommandLineImpl(int argc, char* argv[],
- UsageFlagsAction usage_flag_action,
- OnUndefinedFlag undef_flag_action);
+// This is not a public interface. This interface exists to expose the ability
+// to change help output stream in case of parsing errors. This is used by
+// internal unit tests to validate expected outputs.
+// When this was written, `EXPECT_EXIT` only supported matchers on stderr,
+// but not on stdout.
+std::vector<char*> ParseCommandLineImpl(
+ int argc, char* argv[], UsageFlagsAction usage_flag_action,
+ OnUndefinedFlag undef_flag_action,
+ std::ostream& error_help_output = std::cout);
// --------------------------------------------------------------------
// Inspect original command line