]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs-journal-tool: handle --help cleanly
authorJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 10:10:26 +0000 (11:10 +0100)
committerJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 13:43:54 +0000 (14:43 +0100)
Handle --help before main initialization so that
it works with or without a running mon cluster.

Signed-off-by: John Spray <john.spray@inktank.com>
src/tools/cephfs/cephfs-journal-tool.cc

index 7b0f7785749bb5e4f45ac633fad90292fc642b97..e9083a5acf52561a24b4017ef6676c77df4f0822 100644 (file)
@@ -31,12 +31,21 @@ int main(int argc, const char **argv)
   common_init_finish(g_ceph_context);
 
   JournalTool jt;
+
+  // Handle --help before calling init() so we don't depend on network.
+  if (args.empty() || (args.size() == 1 && (std::string(args[0]) == "--help" || std::string(args[0]) == "-h"))) {
+    jt.usage();
+    return 0;
+  }
+
+  // Connect to mon cluster, download MDS map etc
   int rc = jt.init();
   if (rc != 0) {
       std::cerr << "Error in initialization: " << cpp_strerror(rc) << std::endl;
       return rc;
   }
 
+  // Finally, execute the user's commands
   rc = jt.main(args);
   if (rc != 0) {
     std::cerr << "Error (" << cpp_strerror(rc) << ")" << std::endl;