]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Use _daemon version of argparse functions
authorDan Mick <dan.mick@inktank.com>
Mon, 8 Apr 2013 20:52:32 +0000 (13:52 -0700)
committerDan Mick <dan.mick@inktank.com>
Tue, 9 Apr 2013 00:49:15 +0000 (17:49 -0700)
Allow argparse functions to fail if no argument given by using
special versions that avoid the default CLI behavior of "cerr/exit"

Fixes: #4678
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc

index 0ca0f78bf45f7a3ec1610f7291fcfe54ad81d75a..3ea6d860039cb1fc547f89ca14f7022b45d22e41 100644 (file)
@@ -548,7 +548,8 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
       for (std::vector<const char*>::iterator i = args.begin()+1; i != args.end(); ) {
        if (ceph_argparse_double_dash(args, i))
          break;
-       else if (ceph_argparse_witharg(args, i, &val, "-f", "--format", (char*)NULL))
+       else if (ceph_argparse_witharg_daemon(args, i, &val, "-f", "--format",
+                                             (char*)NULL))
          format = val;
        else if (!epoch) {
          long l = parse_pos_long(*i++, &ss);
index d8d4579f67b1d6935253a0f80741e581481df90b..a49d08a02af215a640124a27f181db6d7eacbc78 100644 (file)
@@ -2483,7 +2483,7 @@ void Monitor::handle_command(MMonCommand *m)
     JSONFormatter *jf = NULL;
     for (vector<const char*>::iterator i = args.begin(); i != args.end();) {
       string val;
-      if (ceph_argparse_witharg(args, i, &val,
+      if (ceph_argparse_witharg_daemon(args, i, &val,
             "-f", "--format", (char*)NULL)) {
         format = val;
       } else {
index af8d7299227d60e39e88564ea1f2ff05c865025b..f1c6dfa3325266b3a0ed6e361079933bd82c34d4 100644 (file)
@@ -222,7 +222,8 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m)
       for (std::vector<const char*>::iterator i = args.begin()+1; i != args.end(); ) {
        if (ceph_argparse_double_dash(args, i))
          break;
-       else if (ceph_argparse_witharg(args, i, &val, "-f", "--format", (char*)NULL))
+       else if (ceph_argparse_witharg_daemon(args, i, &val, "-f", "--format",
+                                             (char*)NULL))
          format = val;
        else if (!epoch) {
          long l = parse_pos_long(*i++, &ss);
index a9d68075cd4cf192631d8111053431172695155f..40103ec402f8188568c41ca75b17b88872316cf3 100644 (file)
@@ -1894,7 +1894,8 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
       for (std::vector<const char*>::iterator i = args.begin()+1; i != args.end(); ) {
        if (ceph_argparse_double_dash(args, i))
          break;
-       else if (ceph_argparse_witharg(args, i, &val, "-f", "--format", (char*)NULL))
+       else if (ceph_argparse_witharg_daemon(args, i, &val, "-f", "--format",
+                                             (char*)NULL))
          format = val;
        else if (!epoch) {
          long l = parse_pos_long(*i++, &ss);
index c05897215cc67ddba4d708b98a19ea23d12974d7..fe50b34da8c24cfb3b785f5a9f16398d766ca667 100644 (file)
@@ -1096,7 +1096,8 @@ bool PGMonitor::preprocess_command(MMonCommand *m)
       for (std::vector<const char*>::iterator i = args.begin()+1; i != args.end(); ) {
        if (ceph_argparse_double_dash(args, i)) {
          break;
-       } else if (ceph_argparse_witharg(args, i, &val, "-f", "--format", (char*)NULL)) {
+       } else if (ceph_argparse_witharg_daemon(args, i, &val, "-f",
+                                               "--format", (char*)NULL)) {
          format = val;
        } else {
          what = *i++;
@@ -1572,14 +1573,14 @@ int PGMonitor::dump_stuck_pg_stats(ostream& ss,
        i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
-    } else if (ceph_argparse_witharg(args, i, &val,
+    } else if (ceph_argparse_witharg_daemon(args, i, &val,
                                     "-f", "--format", (char*)NULL)) {
       if (val != "json" && val != "plain") {
        ss << "format must be json or plain";
        return -EINVAL;
       }
       format = val;
-    } else if (ceph_argparse_withint(args, i, &seconds, &err,
+    } else if (ceph_argparse_withint_daemon(args, i, &seconds, &err,
                                     "-t", "--threshold", (char*)NULL)) {
       if (!err.str().empty()) {
        ss << err.str();