summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-03-06 18:50:08 -0800
committerGitHub <noreply@github.com>2019-03-06 18:50:08 -0800
commit3a5dcc61ffcc54cecdba2cac272be66310ab2f3d (patch)
tree7416ac2fbe2c3497bb9f9cd2cf2fa969e6cfd5c6
parent2c4e9d89d483edc0845eeecd38fa8cffd29217aa (diff)
downloadbinaryen-3a5dcc61ffcc54cecdba2cac272be66310ab2f3d.tar.gz
binaryen-3a5dcc61ffcc54cecdba2cac272be66310ab2f3d.tar.bz2
binaryen-3a5dcc61ffcc54cecdba2cac272be66310ab2f3d.zip
Use stdout for --help message (#1937)
Noramlly --help is considered normal output not error output. For example its normally to pipe the output of --help to a pager.
-rw-r--r--src/support/command-line.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index 384dc5dcd..6882dda7b 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -51,11 +51,11 @@ Options::Options(const std::string& command, const std::string& description)
: debug(false), positional(Arguments::Zero) {
add("--help", "-h", "Show this help message and exit", Arguments::Zero,
[this, command, description](Options* o, const std::string&) {
- std::cerr << command;
- if (positional != Arguments::Zero) std::cerr << ' ' << positionalName;
- std::cerr << "\n\n";
- printWrap(std::cerr, 0, description);
- std::cerr << "\n\nOptions:\n";
+ std::cout << command;
+ if (positional != Arguments::Zero) std::cout << ' ' << positionalName;
+ std::cout << "\n\n";
+ printWrap(std::cout, 0, description);
+ std::cout << "\n\nOptions:\n";
size_t optionWidth = 0;
for (const auto& o : options) {
optionWidth =
@@ -64,12 +64,12 @@ Options::Options(const std::string& command, const std::string& description)
for (const auto& o : options) {
bool long_n_short = o.longName.size() != 0 && o.shortName.size() != 0;
size_t pad = 1 + optionWidth - o.longName.size() - o.shortName.size();
- std::cerr << " " << o.longName << (long_n_short ? ',' : ' ')
+ std::cout << " " << o.longName << (long_n_short ? ',' : ' ')
<< o.shortName << std::string(pad, ' ');
- printWrap(std::cerr, optionWidth + 4, o.description);
- std::cerr << '\n';
+ printWrap(std::cout, optionWidth + 4, o.description);
+ std::cout << '\n';
}
- std::cerr << '\n';
+ std::cout << '\n';
exit(EXIT_SUCCESS);
});
add("--debug", "-d", "Print debug information to stderr", Arguments::Zero,