]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
global: output usage on -h, --help, or no args before contacting mons 20812/head
authorSage Weil <sage@redhat.com>
Thu, 8 Mar 2018 22:36:57 +0000 (16:36 -0600)
committerSage Weil <sage@redhat.com>
Thu, 15 Mar 2018 20:51:55 +0000 (15:51 -0500)
- when there are no arguments, print a short invitation to stderr to
  use -h or --help and exit with an error.
- if we get -h or --help, print usage to stdout, and exit with success.
- do the above *before* making any contact with the cluster.  we should
  not fail to explain usage because the mons are down.
- if there is some other error with the arguments, print an error message,
  but do not spam the user with usage.  Try to use cerr instead of derr.

Signed-off-by: Sage Weil <sage@redhat.com>
41 files changed:
src/ceph_fuse.cc
src/ceph_mds.cc
src/ceph_mgr.cc
src/ceph_mon.cc
src/ceph_osd.cc
src/common/ceph_argparse.cc
src/common/ceph_argparse.h
src/librados-config.cc
src/rbd_replay/rbd-replay.cc
src/rgw/rgw_admin.cc
src/rgw/rgw_main.cc
src/rgw/rgw_object_expirer.cc
src/rgw/rgw_token.cc
src/test/TestSignalHandlers.cc
src/test/cli/ceph-authtool/help.t
src/test/cli/ceph-authtool/manpage.t
src/test/cli/ceph-authtool/simple.t
src/test/cli/ceph-kvstore-tool/help.t
src/test/cli/monmaptool/simple.t
src/test/cli/osdmaptool/missing-argument.t
src/test/cli/radosgw-admin/help.t
src/test/objectstore_bench.cc
src/test/rbd_mirror/random_write.cc
src/test/xattr_bench.cc
src/tools/ceph-client-debug.cc
src/tools/ceph_authtool.cc
src/tools/ceph_kvstore_tool.cc
src/tools/ceph_osdomap_tool.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/JournalTool.cc
src/tools/cephfs/TableTool.cc
src/tools/cephfs/cephfs-data-scan.cc
src/tools/cephfs/cephfs-journal-tool.cc
src/tools/cephfs/cephfs-table-tool.cc
src/tools/crushtool.cc
src/tools/monmaptool.cc
src/tools/osdmaptool.cc
src/tools/rados/rados.cc
src/tools/rbd_ggate/main.cc
src/tools/rbd_mirror/main.cc
src/tools/rbd_nbd/rbd-nbd.cc

index 6e2d21792f605f95812150684a9494d15125d018..916217bead7ef962e6cf6b7fdaae8735c857f132 100644 (file)
@@ -75,7 +75,12 @@ int main(int argc, const char **argv, const char *envp[]) {
   std::vector<const char*> args;
   argv_to_vec(argc, argv, args);
   if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
     usage();
+    exit(0);
   }
 
   std::map<std::string,std::string> defaults = {
@@ -95,8 +100,6 @@ int main(int argc, const char **argv, const char *envp[]) {
     } else if (ceph_argparse_flag(args, i, "--localize-reads", (char*)nullptr)) {
       cerr << "setting CEPH_OSD_FLAG_LOCALIZE_READS" << std::endl;
       filer_flags |= CEPH_OSD_FLAG_LOCALIZE_READS;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)nullptr)) {
-      usage();
     } else {
       ++i;
     }
@@ -210,8 +213,10 @@ int main(int argc, const char **argv, const char *envp[]) {
 
     MonClient *mc = new MonClient(g_ceph_context);
     int r = mc->build_initial_monmap();
-    if (r == -EINVAL)
-      usage();
+    if (r == -EINVAL) {
+      cerr << "failed to generate initial mon list" << std::endl;
+      exit(1);
+    }
     if (r < 0)
       goto out_mc_start_failed;
 
index 9d1a149fb00366ff750025504e98a4290e90b2f2..474c4789916bb1405f8f286cb23020799628cf19 100644 (file)
@@ -73,7 +73,7 @@ static int parse_rank(const char *opt_name, const std::string &val)
   if (!err.empty()) {
     derr << "error parsing " << opt_name << ": failed to parse rank. "
         << "It must be an int." << "\n" << dendl;
-    usage();
+    exit(1);
   }
   return ret;
 }
@@ -99,6 +99,14 @@ int main(int argc, const char **argv)
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args,
                         CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON,
@@ -110,10 +118,6 @@ int main(int argc, const char **argv)
     if (ceph_argparse_double_dash(args, i)) {
       break;
     }
-    else if (ceph_argparse_flag(args, i, "--help", "-h", (char*)NULL)) {
-      // exit(1) will be called in the usage()
-      usage();
-    }
     else if (ceph_argparse_witharg(args, i, &val, "--hot-standby", (char*)NULL)) {
       int r = parse_rank("hot-standby", val);
       dout(0) << "requesting standby_replay for mds." << r << dendl;
index 0f7b75842975e0e189d4f882d7110252f5776874..cabc0fe041d12f5d7d721d230167c72d6a74aa31 100644 (file)
@@ -45,6 +45,13 @@ int main(int argc, const char **argv)
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+  }
 
   map<string,string> defaults = {
     { "keyring", "$mgr_data/keyring" }
@@ -53,12 +60,6 @@ int main(int argc, const char **argv)
                         CODE_ENVIRONMENT_DAEMON, 0,
                         "mgr_data");
 
-  // Handle --help
-  if ((args.size() == 1 && (std::string(args[0]) == "--help" ||
-                           std::string(args[0]) == "-h"))) {
-    usage();
-  }
-
   pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC);
 
   global_init_daemonize(g_ceph_context);
index f3bbc6dc8c2844f647fbebae70885ea9365bbedb..6d97feb7053ea15c19975bed193af6f64456ce30 100644 (file)
@@ -197,6 +197,14 @@ int main(int argc, const char **argv)
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   // We need to specify some default values that may be overridden by the
   // user, that are specific to the monitor.  The options we are overriding
@@ -253,8 +261,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
     } else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
       mkfs = true;
     } else if (ceph_argparse_flag(args, i, "--compact", (char*)NULL)) {
@@ -274,24 +280,24 @@ int main(int argc, const char **argv)
     }
   }
   if (!args.empty()) {
-    derr << "too many arguments: " << args << dendl;
-    usage();
+    cerr << "too many arguments: " << args << std::endl;
+    exit(1);
   }
 
   if (force_sync && !yes_really) {
-    derr << "are you SURE you want to force a sync?  this will erase local data and may\n"
-        << "break your mon cluster.  pass --yes-i-really-mean-it if you do." << dendl;
+    cerr << "are you SURE you want to force a sync?  this will erase local data and may\n"
+        << "break your mon cluster.  pass --yes-i-really-mean-it if you do." << std::endl;
     exit(1);
   }
 
   if (g_conf->mon_data.empty()) {
-    derr << "must specify '--mon-data=foo' data path" << dendl;
-    usage();
+    cerr << "must specify '--mon-data=foo' data path" << std::endl;
+    exit(1);
   }
 
   if (g_conf->name.get_id().empty()) {
-    derr << "must specify id (--id <id> or --name mon.<id>)" << dendl;
-    usage();
+    cerr << "must specify id (--id <id> or --name mon.<id>)" << std::endl;
+    exit(1);
   }
 
   // -- mkfs --
@@ -664,7 +670,6 @@ int main(int argc, const char **argv)
       if (err < 0) {
        derr << argv[0] << ": error generating initial monmap: "
              << cpp_strerror(err) << dendl;
-       usage();
        prefork.exit(1);
       }
       if (tmpmap.contains(g_conf->name.get_id())) {
index 62092a5ac4852778e76ff89b309aa4848c2184e4..6d56103111f30ad263bfc7171ced4b8a9831ba11 100644 (file)
@@ -110,6 +110,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   map<string,string> defaults = {
     // We want to enable leveldb's log, while allowing users to override this
@@ -146,8 +154,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
     } else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
       mkfs = true;
     } else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) {
index a89de95f6e405fb2988e8dc8918128efaa02e184..369234914059905239e8fd2193e4b3337879fed4 100644 (file)
@@ -544,13 +544,26 @@ static void generic_usage(bool is_server)
   cout.flush();
 }
 
+bool ceph_argparse_need_usage(const std::vector<const char*>& args)
+{
+  if (args.empty()) {
+    return true;
+  }
+  for (auto a : args) {
+    if (strcmp(a, "-h") == 0 ||
+       strcmp(a, "--help") == 0) {
+      return true;
+    }
+  }
+  return false;
+}
+
 void generic_server_usage()
 {
   generic_usage(true);
-  exit(1);
 }
+
 void generic_client_usage()
 {
   generic_usage(false);
-  exit(1);
 }
index 900b18f31a797134d544bbfc580a6298a8d1d6cb..465b8452e3548e0b470f65d16ce9d60d8c75e288 100644 (file)
@@ -68,6 +68,7 @@ bool ceph_argparse_binary_flag(std::vector<const char*> &args,
 extern CephInitParameters ceph_argparse_early_args
            (std::vector<const char*>& args, uint32_t module_type,
             std::string *cluster, std::string *conf_file_list);
+extern bool ceph_argparse_need_usage(const std::vector<const char*>& args);
 extern void generic_server_usage();
 extern void generic_client_usage();
 
index a7fb69ba13c45cb9e9002c67fa1628164305951b..1dbb7a101f6c005fef391a6f0ad83934887ace3c 100644 (file)
@@ -37,6 +37,13 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage_exit();
+  }
 
   bool opt_version = false;
   bool opt_vernum = false;
index 72f12c127bb42889420fb606d5444561e0c49a55..f52e75fd98a3d51b974ca59f020d9668e94348a6 100644 (file)
@@ -58,6 +58,14 @@ int main(int argc, const char **argv) {
   vector<const char*> args;
 
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage(argv[0]);
+    exit(0);
+  }
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY, 0);
 
@@ -90,9 +98,6 @@ int main(int argc, const char **argv) {
        cerr << "Unable to parse mapping string: '" << val << "'" << std::endl;
        return 1;
       }
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage(argv[0]);
-      return 0;
     } else if (ceph_argparse_flag(args, i, "--dump-perf-counters", (char*)NULL)) {
       dump_perf_counters = true;
     } else if (get_remainder(*i, "-")) {
index b990fd4f2b46762bcd6721e93d371da355922af6..4113634ac7912185ab4b778b4b77a094cf5962e7 100644 (file)
@@ -2382,6 +2382,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, (const char **)argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                          CODE_ENVIRONMENT_UTILITY, 0);
@@ -2537,9 +2545,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      ceph_abort();
     } else if (ceph_argparse_witharg(args, i, &val, "-i", "--uid", (char*)NULL)) {
       user_id.from_str(val);
     } else if (ceph_argparse_witharg(args, i, &val, "--tenant", (char*)NULL)) {
@@ -2580,8 +2585,7 @@ int main(int argc, const char **argv)
         key_type = KEY_TYPE_S3;
       } else {
         cerr << "bad key type: " << key_type_str << std::endl;
-        usage();
-       ceph_abort();
+        exit(1);
       }
     } else if (ceph_argparse_witharg(args, i, &val, "--job-id", (char*)NULL)) {
       job_id = val;
@@ -2695,8 +2699,7 @@ int main(int argc, const char **argv)
       bucket_id = val;
       if (bucket_id.empty()) {
         cerr << "bad bucket-id" << std::endl;
-        usage();
-       ceph_abort();
+        exit(1);
       }
     } else if (ceph_argparse_witharg(args, i, &val, "--format", (char*)NULL)) {
       format = val;
@@ -2870,7 +2873,7 @@ int main(int argc, const char **argv)
 
   if (args.empty()) {
     usage();
-    ceph_abort();
+    exit(1);
   }
   else {
     const char *prev_cmd = NULL;
@@ -2880,8 +2883,7 @@ int main(int argc, const char **argv)
       opt_cmd = get_cmd(*i, prev_cmd, prev_prev_cmd, &need_more);
       if (opt_cmd < 0) {
        cerr << "unrecognized arg " << *i << std::endl;
-       usage();
-       ceph_abort();
+       exit(1);
       }
       if (!need_more) {
        ++i;
@@ -2892,8 +2894,8 @@ int main(int argc, const char **argv)
     }
 
     if (opt_cmd == OPT_NO_CMD) {
-      usage();
-      ceph_abort();
+      cerr << "no command" << std::endl;
+      exit(1);
     }
 
     /* some commands may have an optional extra param */
@@ -2953,8 +2955,7 @@ int main(int argc, const char **argv)
     formatter = new JSONFormatter(pretty_format);
   else {
     cerr << "unrecognized format: " << format << std::endl;
-    usage();
-    ceph_abort();
+    exit(1);
   }
 
   realm_name = g_conf->rgw_realm;
@@ -5113,8 +5114,7 @@ int main(int argc, const char **argv)
   if (opt_cmd == OPT_LOG_SHOW || opt_cmd == OPT_LOG_RM) {
     if (object.empty() && (date.empty() || bucket_name.empty() || bucket_id.empty())) {
       cerr << "specify an object or a date, bucket and bucket-id" << std::endl;
-      usage();
-      ceph_abort();
+      exit(1);
     }
 
     string oid;
@@ -5212,8 +5212,7 @@ next:
   if (opt_cmd == OPT_POOL_ADD) {
     if (pool_name.empty()) {
       cerr << "need to specify pool to add!" << std::endl;
-      usage();
-      ceph_abort();
+      exit(1);
     }
 
     int ret = store->add_bucket_placement(pool);
@@ -5224,8 +5223,7 @@ next:
   if (opt_cmd == OPT_POOL_RM) {
     if (pool_name.empty()) {
       cerr << "need to specify pool to remove!" << std::endl;
-      usage();
-      ceph_abort();
+      exit(1);
     }
 
     int ret = store->remove_bucket_placement(pool);
index 76374aa6b2cf828b7d45a5008a8bf54c9fd73af6..d0f45861ec469e710ad224ba0fa3f30bacf462ad 100644 (file)
@@ -122,15 +122,15 @@ public:
 
 static int usage()
 {
-  cerr << "usage: radosgw [options...]" << std::endl;
-  cerr << "options:\n";
-  cerr << "  --rgw-region=<region>     region in which radosgw runs\n";
-  cerr << "  --rgw-zone=<zone>         zone in which radosgw runs\n";
-  cerr << "  --rgw-socket-path=<path>  specify a unix domain socket path\n";
-  cerr << "  -m monaddress[:port]      connect to specified monitor\n";
-  cerr << "  --keyring=<path>          path to radosgw keyring\n";
-  cerr << "  --logfile=<logfile>       file to log debug output\n";
-  cerr << "  --debug-rgw=<log-level>/<memory-level>  set radosgw debug level\n";
+  cout << "usage: radosgw [options...]" << std::endl;
+  cout << "options:\n";
+  cout << "  --rgw-region=<region>     region in which radosgw runs\n";
+  cout << "  --rgw-zone=<zone>         zone in which radosgw runs\n";
+  cout << "  --rgw-socket-path=<path>  specify a unix domain socket path\n";
+  cout << "  -m monaddress[:port]      connect to specified monitor\n";
+  cout << "  --keyring=<path>          path to radosgw keyring\n";
+  cout << "  --logfile=<logfile>       file to log debug output\n";
+  cout << "  --debug-rgw=<log-level>/<memory-level>  set radosgw debug level\n";
   generic_server_usage();
 
   return 0;
@@ -179,6 +179,14 @@ int main(int argc, const char **argv)
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   // First, let's determine which frontends are configured.
   int flags = CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS;
@@ -234,13 +242,6 @@ int main(int argc, const char **argv)
                         CODE_ENVIRONMENT_DAEMON,
                         flags, "rgw_data", false);
 
-  for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
-    if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return 0;
-    }
-  }
-
   // maintain existing region root pool for new multisite objects
   if (!g_conf->rgw_region_root_pool.empty()) {
     const char *root_pool = g_conf->rgw_region_root_pool.c_str();
index ec7faf29151bd78599059a97997f943275ee8871..759f0c3dd255aa9f300758c3da7d4f8f80884e67 100644 (file)
@@ -57,6 +57,14 @@ int main(const int argc, const char **argv)
 {
   vector<const char *> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_DAEMON,
@@ -65,9 +73,6 @@ int main(const int argc, const char **argv)
   for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return 0;
     }
   }
 
index 18e30e33526bb4695db004f3b3adc88b0fb8af46..705bdecfbf8b335c583873b46a8e4b1091b84391 100644 (file)
@@ -62,6 +62,14 @@ int main(int argc, char **argv)
   std::string val;
   vector<const char*> args;
   argv_to_vec(argc, (const char **)argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY, 0);
@@ -109,7 +117,6 @@ int main(int argc, char **argv)
 
   if ((! do_encode) ||
       (type == RGWToken::TOKEN_NONE)) {
-    usage();
     return -EINVAL;
   }
 
index 1f24c8f964051585a0ad1d55d17697cf90422174..74f819675e6c4ca74b88fa106dbb2a51d4154b57 100644 (file)
@@ -66,10 +66,10 @@ static void infinite_recursion_test()
 
 static void usage()
 {
-  cerr << "usage: TestSignalHandlers [test]" << std::endl;
-  cerr << "--simple_segv: run simple_segv test" << std::endl;
-  cerr << "--infinite_recursion: run infinite_recursion test" << std::endl;
-  generic_client_usage(); // Will exit()
+  cout << "usage: TestSignalHandlers [test]" << std::endl;
+  cout << "--simple_segv: run simple_segv test" << std::endl;
+  cout << "--infinite_recursion: run infinite_recursion test" << std::endl;
+  generic_client_usage();
 }
 
 typedef void (*test_fn_t)(void);
@@ -78,6 +78,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
@@ -88,20 +96,18 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
     } else if (ceph_argparse_flag(args, i, "--infinite_recursion", (char*)NULL)) {
       fn = infinite_recursion_test;
     } else if (ceph_argparse_flag(args, i, "-s", "--simple_segv", (char*)NULL)) {
       fn = simple_segv_test;
     } else {
-      cerr << "Garbage at end of command line." << std::endl;
-      usage();
+      cerr << "unrecognized argument: " << *i << std::endl;
+      exit(1);
     }
   }
   if (!fn) {
     std::cerr << "Please select a test to run. Type -h for help." << std::endl;
-    usage();
+    exit(1);
   }
   fn();
   return 0;
index 9a6c88357f7cd1088e306a33fb39e4d41befecf2..77174b835aca60932438274e679c776e1a7f7d1d 100644 (file)
@@ -1,6 +1,5 @@
 # TODO synchronize with man page
   $ ceph-authtool --help
-  no command specified
   usage: ceph-authtool keyringfile [OPTIONS]...
   where the options are:
     -l, --list                    will list all keys and capabilities present in
index f84b79457a14eecb9a82d3b9edd0b248b67d4d62..3201aa37b2a5332194676d0abf3dd4a720c1fb9b 100644 (file)
@@ -1,27 +1,5 @@
   $ ceph-authtool
-  ceph-authtool: must specify filename
-  usage: ceph-authtool keyringfile [OPTIONS]...
-  where the options are:
-    -l, --list                    will list all keys and capabilities present in
-                                  the keyring
-    -p, --print-key               will print an encoded key for the specified
-                                  entityname. This is suitable for the
-                                  'mount -o secret=..' argument
-    -C, --create-keyring          will create a new keyring, overwriting any
-                                  existing keyringfile
-    -g, --gen-key                 will generate a new secret key for the
-                                  specified entityname
-    --gen-print-key               will generate a new secret key without set it
-                                  to the keyringfile, prints the secret to stdout
-    --import-keyring FILE         will import the content of a given keyring
-                                  into the keyringfile
-    -n NAME, --name NAME          specify entityname to operate on
-    -u AUID, --set-uid AUID       sets the auid (authenticated user id) for the
-                                  specified entityname
-    -a BASE64, --add-key BASE64   will add an encoded key to the keyring
-    --cap SUBSYSTEM CAPABILITY    will set the capability for given subsystem
-    --caps CAPSFILE               will set all of capabilities associated with a
-                                  given key, for all subsystems
+  ceph-authtool: -h or --help for usage
   [1]
 
 # demonstrate that manpage examples fail without config
index 35905ad07267dc8a1cb0346808c955332c5a1af0..bf3fc1036148acc8ca8a4317cd5e38b79e7798ca 100644 (file)
@@ -1,25 +1,3 @@
   $ ceph-authtool
-  ceph-authtool: must specify filename
-  usage: ceph-authtool keyringfile [OPTIONS]...
-  where the options are:
-    -l, --list                    will list all keys and capabilities present in
-                                  the keyring
-    -p, --print-key               will print an encoded key for the specified
-                                  entityname. This is suitable for the
-                                  'mount -o secret=..' argument
-    -C, --create-keyring          will create a new keyring, overwriting any
-                                  existing keyringfile
-    -g, --gen-key                 will generate a new secret key for the
-                                  specified entityname
-    --gen-print-key               will generate a new secret key without set it
-                                  to the keyringfile, prints the secret to stdout
-    --import-keyring FILE         will import the content of a given keyring
-                                  into the keyringfile
-    -n NAME, --name NAME          specify entityname to operate on
-    -u AUID, --set-uid AUID       sets the auid (authenticated user id) for the
-                                  specified entityname
-    -a BASE64, --add-key BASE64   will add an encoded key to the keyring
-    --cap SUBSYSTEM CAPABILITY    will set the capability for given subsystem
-    --caps CAPSFILE               will set all of capabilities associated with a
-                                  given key, for all subsystems
+  ceph-authtool: -h or --help for usage
   [1]
index 9fb3e1de9d830395be7d08207dc1d39d5f7f3ad5..eab57fdb5bc3fa2150670fe193f1c0c0573a8435 100644 (file)
@@ -18,4 +18,3 @@
     compact-range <prefix> <start> <end>
     repair
   
-  [1]
index cee2ab56767d5986f87e8e4578b8003371179b84..48c56911739b879d81e11be44528a3bf49256c84 100644 (file)
@@ -1,9 +1,3 @@
   $ monmaptool
-  monmaptool: must specify monmap filename
-   usage: [--print] [--create [--clobber][--fsid uuid]]
-          [--generate] [--set-initial-members]
-          [--add name 1.2.3.4:567] [--rm name]
-          [--feature-list [plain|parseable]]
-          [--feature-set <value> [--optional|--persistent]]
-          [--feature-unset <value> [--optional|--persistent]] <mapfilename>
+  monmaptool: -h or --help for usage
   [1]
index db1745bd857d56e9c1bb406e5a92151f399fc960..de9b800732397ed9acb58c51a8c4385f6074df94 100644 (file)
@@ -1,26 +1,3 @@
   $ osdmaptool
-  osdmaptool: must specify osdmap filename
-   usage: [--print] [--createsimple <numosd> [--clobber] [--pg_bits <bitsperosd>]] <mapfilename>
-     --export-crush <file>   write osdmap's crush map to <file>
-     --import-crush <file>   replace osdmap's crush map with <file>
-     --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
-     --test-map-pgs-dump [--pool <poolid>] map all pgs
-     --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
-     --health                dump health checks
-     --mark-up-in            mark osds up and in (but do not persist)
-     --mark-out <osdid>      mark an osd as out (but do not persist)
-     --with-default-pool     include default pool when creating map
-     --clear-temp            clear pg_temp and primary_temp
-     --test-random           do random placements
-     --test-map-pg <pgid>    map a pgid to osds
-     --test-map-object <objectname> [--pool <poolid>] map an object to osds
-     --upmap-cleanup <file>  clean up pg_upmap[_items] entries, writing
-                             commands to <file> [default: - for stdout]
-     --upmap <file>          calculate pg upmap entries to balance pg layout
-                             writing commands to <file> [default: - for stdout]
-     --upmap-max <max-count> set max upmap entries to calculate [default: 100]
-     --upmap-deviation <max-deviation>
-                             max deviation from target [default: .01]
-     --upmap-pool <poolname> restrict upmap balancing to 1 or more pools
-     --upmap-save            write modified OSDMap with upmap changes
+  osdmaptool: -h or --help for usage
   [1]
index a7a388e14ea7c738012a6c2bc0ddc1663a31ae14..9fd46c4d0cace9886e22fd5687c69e03d4b610ef 100644 (file)
     --setgroup GROUP  set gid to group or gid
     --version         show version and quit
   
-  [1]
 
 
index 406dce3a75e1559e3c4ac1da5e593793a6359c08..7b67cba724b4e418c61b14dd85789adef6ac122b 100644 (file)
@@ -20,7 +20,7 @@
 
 static void usage()
 {
-  derr << "usage: ceph_objectstore_bench [flags]\n"
+  cout << "usage: ceph_objectstore_bench [flags]\n"
       "         --size\n"
       "               total size in bytes\n"
       "         --block-size\n"
@@ -30,7 +30,7 @@ static void usage()
       "         --threads\n"
       "               number of threads to carry out this workload\n"
       "         --multi-object\n"
-      "               have each thread write to a separate object\n" << dendl;
+    "         have each thread write to a separate object\n" << std::endl;
   generic_server_usage();
 }
 
@@ -167,13 +167,13 @@ int main(int argc, const char *argv[])
       std::string err;
       if (!cfg.size.parse(val, &err)) {
         derr << "error parsing size: " << err << dendl;
-        usage();
+        exit(1);
       }
     } else if (ceph_argparse_witharg(args, i, &val, "--block-size", (char*)nullptr)) {
       std::string err;
       if (!cfg.block_size.parse(val, &err)) {
         derr << "error parsing block-size: " << err << dendl;
-        usage();
+        exit(1);
       }
     } else if (ceph_argparse_witharg(args, i, &val, "--repeats", (char*)nullptr)) {
       cfg.repeats = atoi(val.c_str());
@@ -183,7 +183,7 @@ int main(int argc, const char *argv[])
       cfg.multi_object = true;
     } else {
       derr << "Error: can't understand argument: " << *i << "\n" << dendl;
-      usage();
+      exit(1);
     }
   }
 
index 4b41ef044f1710e2b32a1734d1698501f4e93091..2d89924d8ea4a3621fb4a57bfd82a9ba2bcae129 100644 (file)
@@ -154,18 +154,19 @@ int main(int argc, const char **argv)
 {
   std::vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
                         CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
 
-  for (auto i = args.begin(); i != args.end(); ++i) {
-    if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return EXIT_SUCCESS;
-    }
-  }
-
   if (args.size() < 2) {
     usage();
     return EXIT_FAILURE;
index 23b7fd44307cda96e4363df681a54d01e34d9810..b5a2aded78f27cf5fca17cf6b60ac8025212341f 100644 (file)
@@ -151,6 +151,14 @@ uint64_t do_run(ObjectStore *store, int attrsize, int numattrs,
 int main(int argc, char **argv) {
   vector<const char*> args;
   argv_to_vec(argc, (const char **)argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage(argv[0]);
+    exit(0);
+  }
 
   auto cct = global_init(0, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
index 116a19543ed836cc551034e57071114f21feb488..44f860e6a732fad3c3438ccc0b089151f3f4bcb6 100644 (file)
@@ -84,6 +84,14 @@ int main(int argc, const char **argv)
   // Argument handling
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
@@ -94,7 +102,8 @@ int main(int argc, const char **argv)
 
   // Expect exactly one positional argument (inode number)
   if (args.size() != 1) {
-    usage();
+    cerr << "missing position argument (inode number)" << std::endl;
+    exit(1);
   }
   char const *inode_str = args[0];
   inodeno_t inode = strtoll(inode_str, NULL, 0);
index 23370f7307e4ccbb656844bf785d6fe6735d1bd7..b2120c9beb810372f24b16fec6267c07b62889de 100644 (file)
@@ -62,6 +62,15 @@ int main(int argc, const char **argv)
   map<string,bufferlist> caps;
   std::string fn;
 
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
+
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
                         CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
index 2103efc87acad991ef03c3424a4f241d7e98b8bd..21ca515f0ae4e4188dd145ab929c32b5edf76ddb 100644 (file)
@@ -292,7 +292,7 @@ class StoreTool
 
 void usage(const char *pname)
 {
-  std::cerr << "Usage: " << pname << " <leveldb|rocksdb|bluestore-kv> <store path> command [args...]\n"
+  std::cout << "Usage: " << pname << " <leveldb|rocksdb|bluestore-kv> <store path> command [args...]\n"
     << "\n"
     << "Commands:\n"
     << "  list [prefix]\n"
@@ -317,6 +317,14 @@ int main(int argc, const char *argv[])
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage(argv[0]);
+    exit(0);
+  }
 
   auto cct = global_init(
       NULL, args,
index b6b59c26ea3bc55244ff32de76b89223226fca9f..b377aa163aa100e467807fa5d312a7abfa4c0c8e 100644 (file)
@@ -70,6 +70,11 @@ int main(int argc, char **argv) {
 
   if (vm.count("debug")) debug = true;
 
+  if (vm.count("help")) {
+    std::cerr << desc << std::endl;
+    return 1;
+  }
+
   auto cct = global_init(
     NULL, ceph_options, CEPH_ENTITY_TYPE_OSD,
     CODE_ENVIRONMENT_UTILITY_NODOUT, 0);
@@ -82,11 +87,6 @@ int main(int argc, char **argv) {
   }
   g_conf->apply_changes(NULL);
 
-  if (vm.count("help")) {
-    std::cerr << desc << std::endl;
-    return 1;
-  }
-
   if (vm.count("omap-path") == 0) {
     std::cerr << "Required argument --omap-path" << std::endl;
     return 1;
index f8bf524097a7a8017b79ffbde39f5ecea2090dcd..e2e0233924e1d2429598de4725c6abcfafcfb0da 100644 (file)
@@ -136,7 +136,7 @@ int DataScan::main(const std::vector<const char*> &args)
   // Parse args
   // ==========
   if (args.size() < 1) {
-    usage();
+    cerr << "missing position argument" << std::endl;
     return -EINVAL;
   }
 
@@ -248,7 +248,6 @@ int DataScan::main(const std::vector<const char*> &args)
       command == "cleanup") {
     if (data_pool_name.empty()) {
       std::cerr << "Data pool not specified" << std::endl;
-      usage();
       return -EINVAL;
     }
 
index 2af6a918c3fad4de4592329454e27c82f7c93a2b..95a06111cdb26b5f7db77b83ac2cf65d99061d9f 100644 (file)
@@ -88,7 +88,7 @@ int JournalTool::main(std::vector<const char*> &argv)
   // Common arg parsing
   // ==================
   if (argv.empty()) {
-    usage();
+    cerr << "missing positional argument" << std::endl;
     return -EINVAL;
   }
 
@@ -171,8 +171,7 @@ int JournalTool::main(std::vector<const char*> &argv)
     } else if (type == std::string("mdlog") && mode == std::string("event")) {
       r = main_event(argv);
     } else {
-      derr << "Bad command '" << mode << "'" << dendl;
-      usage();
+      cerr << "Bad command '" << mode << "'" << std::endl;
       return -EINVAL;
     }
 
@@ -217,12 +216,10 @@ int JournalTool::main_journal(std::vector<const char*> &argv)
         force = true;
       } else {
         std::cerr << "Unknown argument " << argv[1] << std::endl;
-        usage();
         return -EINVAL;
       }
     } else if (argv.size() > 2) {
       std::cerr << "Too many arguments!" << std::endl;
-      usage();
       return -EINVAL;
     }
     return journal_reset(force);
@@ -340,13 +337,11 @@ int JournalTool::main_event(std::vector<const char*> &argv)
   std::string command = *(arg++);
   if (command != "get" && command != "splice" && command != "recover_dentries") {
     derr << "Unknown argument '" << command << "'" << dendl;
-    usage();
     return -EINVAL;
   }
 
   if (arg == argv.end()) {
     derr << "Incomplete command line" << dendl;
-    usage();
     return -EINVAL;
   }
 
@@ -361,15 +356,14 @@ int JournalTool::main_event(std::vector<const char*> &argv)
   // Parse output options
   // ====================
   if (arg == argv.end()) {
-    derr << "Missing output command" << dendl;
-    usage();
+    cerr << "Missing output command" << std::endl;
+    return -EINVAL;
   }
   std::string output_style = *(arg++);
   if (output_style != "binary" && output_style != "json" &&
       output_style != "summary" && output_style != "list") {
-      derr << "Unknown argument: '" << output_style << "'" << dendl;
-      usage();
-      return -EINVAL;
+    cerr << "Unknown argument: '" << output_style << "'" << std::endl;
+    return -EINVAL;
   }
 
   std::string output_path = "dump";
@@ -384,8 +378,7 @@ int JournalTool::main_event(std::vector<const char*> &argv)
       assert(r == 0);
       other_pool = true;
     } else {
-      derr << "Unknown argument: '" << *arg << "'" << dendl;
-      usage();
+      cerr << "Unknown argument: '" << *arg << "'" << std::endl;
       return -EINVAL;
     }
   }
@@ -500,8 +493,7 @@ int JournalTool::main_event(std::vector<const char*> &argv)
 
 
   } else {
-    derr << "Unknown argument '" << command << "'" << dendl;
-    usage();
+    cerr << "Unknown argument '" << command << "'" << std::endl;
     return -EINVAL;
   }
 
index e4cfa8eb71d167b23051ec1141517469cdd8b5a5..9c522fab1d203eab13c33add38f837ec21552fdd 100644 (file)
@@ -319,7 +319,7 @@ int TableTool::main(std::vector<const char*> &argv)
 
   // Require at least 3 args <rank> <mode> <arg> [args...]
   if (argv.size() < 3) {
-    usage();
+    cerr << "missing required 3 arguments" << std::endl;
     return -EINVAL;
   }
 
@@ -368,8 +368,7 @@ int TableTool::main(std::vector<const char*> &argv)
       jf.dump_int("result", r);
       jf.close_section();
     } else {
-      derr << "Invalid table '" << table << "'" << dendl;
-      usage();
+      cerr << "Invalid table '" << table << "'" << std::endl;
       return -EINVAL;
     }
   } else if (mode == "show") {
@@ -391,8 +390,7 @@ int TableTool::main(std::vector<const char*> &argv)
       }
       jf.close_section();
     } else {
-      derr << "Invalid table '" << table << "'" << dendl;
-      usage();
+      cerr << "Invalid table '" << table << "'" << std::endl;
       return -EINVAL;
     }
   } else if (mode == "take_inos") {
@@ -407,8 +405,7 @@ int TableTool::main(std::vector<const char*> &argv)
       return InoTableHandler(rank).take_inos(&io, ino, f);
     }, &jf);
   } else {
-    derr << "Invalid mode '" << mode << "'" << dendl;
-    usage();
+    cerr << "Invalid mode '" << mode << "'" << std::endl;
     return -EINVAL;
   }
 
index 3e6d81217fd1019812fc37fd0165f38383cea318..9de8384ab6a314b57a8a30899b3550f3918af48f 100644 (file)
@@ -13,18 +13,20 @@ int main(int argc, const char **argv)
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
 
-  auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
-                         CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
   DataScan data_scan;
-
-  // 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"))) {
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
     data_scan.usage();
-    return 0;
+    exit(0);
   }
 
+  auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+                         CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
   // Connect to mon cluster, download MDS map etc
   int rc = data_scan.init();
   if (rc != 0) {
index f9537b2d449a92bdbfdb647fb06e58979891522c..b8b22f664824f965176ae6c0486684e93eef6ccf 100644 (file)
@@ -25,18 +25,20 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  JournalTool jt;
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    jt.usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                             CODE_ENVIRONMENT_UTILITY, 0);
   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();
index 7c8e23f324019e0ee08e9831cb1e419fc427683f..d2b5c5253c5361991614807d61168bc80399e74a 100644 (file)
@@ -13,17 +13,20 @@ int main(int argc, const char **argv)
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
 
+  TableTool tt;
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    tt.usage();
+    exit(0);
+  }
+
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                          CODE_ENVIRONMENT_UTILITY, 0);
   common_init_finish(g_ceph_context);
 
-  TableTool tt;
-
-  // 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"))) {
-    tt.usage();
-    return 0;
-  }
 
   // Connect to mon cluster, download MDS map etc
   int rc = tt.init();
index e640f2ada9204e0ffd4c773fe69918497b38f9d4..12b7cfd10d44ed6cec0df788c516ba4ec02ac503 100644 (file)
@@ -355,6 +355,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   const char *me = argv[0];
   std::string infn, srcfn, outfn, add_name, add_type, remove_name, reweight_name;
@@ -425,9 +433,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return EXIT_SUCCESS;
     } else if (ceph_argparse_witharg(args, i, &val, "-d", "--decompile", (char*)NULL)) {
       infn = val;
       decompile = true;
index 067e2fa5926ef2e10d47985b761c6e0dbeccbe28..be06973e9a120ed219103e5366a4307b06dccc7f 100644 (file)
@@ -167,6 +167,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   const char *me = argv[0];
 
@@ -190,8 +198,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
     } else if (ceph_argparse_flag(args, i, "-p", "--print", (char*)NULL)) {
       print = true;
     } else if (ceph_argparse_flag(args, i, "--create", (char*)NULL)) {
index 5a7c33441e9a086d151f401fc7ec0cf13cf41b62..faf1f750fb8ad2ac1b2c17c1b9e0064032939cf7 100644 (file)
@@ -88,6 +88,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
@@ -136,8 +144,6 @@ int main(int argc, const char **argv)
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
     } else if (ceph_argparse_flag(args, i, "-p", "--print", (char*)NULL)) {
       print = true;
     } else if (ceph_argparse_witharg(args, i, &val, err, "--dump", (char*)NULL)) {
index c1fe40cc98c6be7f9cfcd7ae56809c309c789ccf..4fd2d696508eb08b20f084aea8699c278b1f78c9 100644 (file)
@@ -3707,6 +3707,14 @@ int main(int argc, const char **argv)
 {
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage(cout);
+    exit(0);
+  }
 
   std::map < std::string, std::string > opts;
   std::string val;
@@ -3742,9 +3750,6 @@ int main(int argc, const char **argv)
   for (i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage(cout);
-      exit(0);
     } else if (ceph_argparse_flag(args, i, "--force-full", (char*)NULL)) {
       opts["force-full"] = "true";
     } else if (ceph_argparse_flag(args, i, "-d", "--delete-after", (char*)NULL)) {
index e476ebb4c7a4a6f3bc0e36397460ac1c28b31d3b..44a075237f1be019dd96ae53b59aa40f8029de3d 100644 (file)
@@ -396,6 +396,14 @@ int main(int argc, const char *argv[]) {
   vector<const char*> args;
 
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   std::string conf_file_list;
   std::string cluster;
index 4690883d6e30e558c092620c7cf6878f6aabc597..84d7a9de6a46f3bb8239ddfde8dd279a23dda3c2 100644 (file)
@@ -33,18 +33,19 @@ int main(int argc, const char **argv)
 {
   std::vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_DAEMON,
                         CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
 
-  for (auto i = args.begin(); i != args.end(); ++i) {
-    if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return EXIT_SUCCESS;
-    }
-  }
-
   if (g_conf->daemonize) {
     global_init_daemonize(g_ceph_context);
   }
index 1ef12b481d00de53836dc825951f7cc6e197ce95..f2608d8b84713b3d0189637f8654ec2536bbb4a1 100644 (file)
@@ -665,6 +665,14 @@ static int do_map(int argc, const char *argv[], Config *cfg)
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    exit(1);
+  }
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
 
   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
                          CODE_ENVIRONMENT_DAEMON,