]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
command/cmdparse: use -- to separate positional from non-positional args
authorSage Weil <sage@newdream.net>
Fri, 21 May 2021 22:01:35 +0000 (18:01 -0400)
committerSage Weil <sage@newdream.net>
Tue, 1 Jun 2021 18:45:07 +0000 (14:45 -0400)
In a command definition, separate the non-positional args with "--".

Signed-off-by: Sage Weil <sage@newdream.net>
src/common/cmdparse.cc

index f1756a292a5215ec8b3bd978873d18778d7704f0..03f634123eb1683e423cea7f6f81ee9c2c028a5f 100644 (file)
@@ -138,13 +138,20 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd)
 
   stringstream ss(cmd);
   std::string word;
+  bool positional = true;
 
   while (std::getline(ss, word, ' ')) {
+    if (word == "--") {
+      positional = false;
+      continue;
+    }
+
     // if no , or =, must be a plain word to put out
     if (word.find_first_of(",=") == string::npos) {
       f->dump_string("arg", word);
       continue;
     }
+
     // accumulate descriptor keywords in desckv
     auto desckv = cmddesc_get_args(word);
     // name the individual desc object based on the name key
@@ -168,7 +175,13 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd)
     }
 
     // dump all the keys including name into the array
+    if (!positional) {
+      desckv["positional"] = "false";
+    }
     for (auto [key, value] : desckv) {
+      if (key == "positional" && !HAVE_FEATURE(features, SERVER_QUINCY)) {
+       continue;
+      }
       f->dump_string(key, value);
     }
     f->close_section(); // attribute object for individual desc