From: Kefu Chai Date: Tue, 16 Jul 2019 06:53:57 +0000 (+0800) Subject: tools/ceph_conf: send help to cout in case of '--help' X-Git-Tag: v14.2.17~90^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=869ae1df551f5e9b56f4c696bfa6a04313d7e175;p=ceph.git tools/ceph_conf: send help to cout in case of '--help' we should not write to cerr if use asks for help message explicitly Signed-off-by: Kefu Chai (cherry picked from commit a3a20576378ed8097e650052aa3c9c7f61b2f28a) --- diff --git a/src/tools/ceph_conf.cc b/src/tools/ceph_conf.cc index d4d003b7577ab..48511e5c14223 100644 --- a/src/tools/ceph_conf.cc +++ b/src/tools/ceph_conf.cc @@ -23,7 +23,7 @@ using std::deque; using std::string; -static void usage() +static void usage(std::ostream& out) { // TODO: add generic_usage once cerr/derr issues are resolved out << R"(Ceph configuration query tool @@ -156,7 +156,7 @@ static int dump_all(const string& format) return 0; } cerr << "format '" << format << "' not recognized." << std::endl; - usage(); + usage(cerr); return 1; } } @@ -213,7 +213,7 @@ int main(int argc, const char **argv) size_t pos = val.find_first_of('='); if (pos == string::npos) { cerr << "expecting argument like 'key=value' for --filter-key-value (not '" << val << "')" << std::endl; - usage(); + usage(cerr); return EXIT_FAILURE; } string key(val, 0, pos); @@ -234,7 +234,7 @@ int main(int argc, const char **argv) cerr << " " << quoted(arg); } cerr << std::endl; - usage(); + usage(cerr); return EXIT_FAILURE; } } @@ -242,7 +242,7 @@ int main(int argc, const char **argv) cct->_log->flush(); if (action == "help") { - usage(); + usage(cout); return EXIT_SUCCESS; } else if (action == "list-sections") { return list_sections(section_list_prefix, filter_key, filter_key_value);