]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph_conf: send help to cout in case of '--help'
authorKefu Chai <kchai@redhat.com>
Tue, 16 Jul 2019 06:53:57 +0000 (14:53 +0800)
committerBrad Hubbard <bhubbard@redhat.com>
Mon, 14 Dec 2020 02:08:05 +0000 (12:08 +1000)
we should not write to cerr if use asks for help message explicitly

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit a3a20576378ed8097e650052aa3c9c7f61b2f28a)

src/tools/ceph_conf.cc

index d4d003b7577ab6ae4642b2cd29bd4a20d420afa5..48511e5c142236cfd2bb6ac1b050dd9556467c96 100644 (file)
@@ -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);