From c441d35bc19aa876e3b87770015f5606e65c0ef0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 May 2021 18:01:35 -0400 Subject: [PATCH] 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 --- src/common/cmdparse.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index f1756a292a5..03f634123eb 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 -- 2.39.5