From 3a5dcc61ffcc54cecdba2cac272be66310ab2f3d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 6 Mar 2019 18:50:08 -0800 Subject: 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. --- src/support/command-line.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') 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, -- cgit v1.2.3