]> 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 <dmick@danceorelse.org>
Tue, 9 Apr 2013 08:38:01 +0000 (01:38 -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>
(cherry picked from commit be801f6c506d9fbfb6c06afe94663abdb0037be5)

Conflicts:
src/mon/Monitor.cc

src/mon/MDSMonitor.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc

index 72168ac963826c3abf5212029f232ccce5839599..be6738a03238b774c5554304554dac8ab016bd35 100644 (file)
@@ -539,7 +539,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 196edeee476d955940e80bf29a69852d2d93c480..523782aed3b6844ca247ecc82d1ce2b62204bb9a 100644 (file)
@@ -181,7 +181,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 4ac50c0f554bb8ee5360464cce01688a3328053f..786ccd1929af5161f04662a8e915ddce0197215e 100644 (file)
@@ -1721,7 +1721,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 7e9b83ba5e0d7b72c97daff25183266fd65d5b0f..1baaa59e28c60c9484dc0b6a9e4a6f9336bc6bff 100644 (file)
@@ -919,7 +919,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++;
@@ -1395,14 +1396,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();