]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cosd.cc: use new argument parsing functions
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 6 Sep 2011 22:07:55 +0000 (15:07 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 6 Sep 2011 22:28:45 +0000 (15:28 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/cosd.cc

index 7ff132723a371a713a1c6a784984cf59f706b62e..82fa291901ca898cf3716e0d535fadb692069120 100644 (file)
@@ -50,7 +50,6 @@ void usage()
 
 int main(int argc, const char **argv) 
 {
-  DEFINE_CONF_VARS(usage);
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
   env_to_vec(args);
@@ -65,31 +64,41 @@ int main(int argc, const char **argv)
   bool mkkey = false;
   bool flushjournal = false;
   bool convertfilestore = false;
-  char *dump_pg_log = 0;
-  FOR_EACH_ARG(args) {
-    if (CEPH_ARGPARSE_EQ("mkfs", '\0')) {
+  std::string dump_pg_log;
+
+  std::string val;
+  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();
+      exit(0);
+    } else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
       mkfs = true;
-    } else if (CEPH_ARGPARSE_EQ("mkjournal", '\0')) {
+    } else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) {
       mkjournal = true;
-    } else if (CEPH_ARGPARSE_EQ("mkkey", '\0')) {
+    } else if (ceph_argparse_flag(args, i, "--mkkey", (char*)NULL)) {
       mkkey = true;
-    } else if (CEPH_ARGPARSE_EQ("flush-journal", '\0')) {
+    } else if (ceph_argparse_flag(args, i, "--flush-journal", (char*)NULL)) {
       flushjournal = true;
-    } else if (CEPH_ARGPARSE_EQ("convert-filestore", '\0')) {
+    } else if (ceph_argparse_flag(args, i, "--convert-filestore", (char*)NULL)) {
       convertfilestore = true;
-    } else if (CEPH_ARGPARSE_EQ("dump-pg-log", '\0')) {
-      CEPH_ARGPARSE_SET_ARG_VAL(&dump_pg_log, OPT_STR);
+    } else if (ceph_argparse_witharg(args, i, &val, "--dump-pg-log", (char*)NULL)) {
+      dump_pg_log = val;
     } else {
-      derr << "unrecognized arg " << args[i] << dendl;
-      usage();
+      ++i;
     }
   }
+  if (!args.empty()) {
+    derr << "unrecognized arg " << args[0] << dendl;
+    usage();
+  }
 
-  if (dump_pg_log) {
+  if (!dump_pg_log.empty()) {
     common_init_finish(g_ceph_context);
     bufferlist bl;
     std::string error;
-    int r = bl.read_file(dump_pg_log, &error);
+    int r = bl.read_file(dump_pg_log.c_str(), &error);
     if (r >= 0) {
       PG::Log::Entry e;
       bufferlist::iterator p = bl.begin();