From: John Spray Date: Tue, 20 May 2014 10:10:26 +0000 (+0100) Subject: tools/cephfs-journal-tool: handle --help cleanly X-Git-Tag: v0.82~48^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2621b5d9e27b46d3dba50ab82b2efb15ff68537a;p=ceph.git tools/cephfs-journal-tool: handle --help cleanly Handle --help before main initialization so that it works with or without a running mon cluster. Signed-off-by: John Spray --- diff --git a/src/tools/cephfs/cephfs-journal-tool.cc b/src/tools/cephfs/cephfs-journal-tool.cc index 7b0f7785749..e9083a5acf5 100644 --- a/src/tools/cephfs/cephfs-journal-tool.cc +++ b/src/tools/cephfs/cephfs-journal-tool.cc @@ -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;