From: Sage Weil Date: Fri, 21 May 2021 22:01:35 +0000 (-0400) Subject: command/cmdparse: use -- to separate positional from non-positional args X-Git-Tag: v17.1.0~1726^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c441d35bc19aa876e3b87770015f5606e65c0ef0;p=ceph.git command/cmdparse: use -- to separate positional from non-positional args In a command definition, separate the non-positional args with "--". Signed-off-by: Sage Weil --- diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index f1756a292a52..03f634123eb1 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -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