From 3d56f607b7083aff7606aeb19068d48f19a73059 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 7 Jun 2022 15:15:39 +0800 Subject: [PATCH] Handle multiple_token flag in generate-command-help.rb (#10822) Currently generate-command.help.rb dose not handle the multiple_token flag, handle this flag in this PR. The format is the same as redis-cli rendering. ```diff - bitfield_ro key GET encoding offset [encoding offset ...] + bitfield_ro key GET encoding offset [GET encoding offset ...] ``` Re run generate-command-code.py which was forget in #10820. Also change the flag value from string to bool, like "true" to true --- src/commands.c | 2 +- src/commands/bitfield.json | 2 +- src/commands/bitfield_ro.json | 4 ++-- src/help.h | 12 ++++++------ utils/generate-command-help.rb | 6 +++++- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/commands.c b/src/commands.c index 3a46d3f70..837e0eed5 100644 --- a/src/commands.c +++ b/src/commands.c @@ -124,7 +124,7 @@ struct redisCommandArg BITFIELD_RO_encoding_offset_Subargs[] = { /* BITFIELD_RO argument table */ struct redisCommandArg BITFIELD_RO_Args[] = { {"key",ARG_TYPE_KEY,0,NULL,NULL,NULL,CMD_ARG_NONE}, -{"encoding_offset",ARG_TYPE_BLOCK,-1,"GET",NULL,NULL,CMD_ARG_MULTIPLE,.subargs=BITFIELD_RO_encoding_offset_Subargs}, +{"encoding_offset",ARG_TYPE_BLOCK,-1,"GET",NULL,NULL,CMD_ARG_MULTIPLE|CMD_ARG_MULTIPLE_TOKEN,.subargs=BITFIELD_RO_encoding_offset_Subargs}, {0} }; diff --git a/src/commands/bitfield.json b/src/commands/bitfield.json index 5c6fc6105..d1bec969e 100644 --- a/src/commands/bitfield.json +++ b/src/commands/bitfield.json @@ -46,7 +46,7 @@ { "name": "operation", "type": "oneof", - "multiple": "true", + "multiple": true, "arguments": [ { "token": "GET", diff --git a/src/commands/bitfield_ro.json b/src/commands/bitfield_ro.json index cb93fa63d..21390b95b 100644 --- a/src/commands/bitfield_ro.json +++ b/src/commands/bitfield_ro.json @@ -43,8 +43,8 @@ "token": "GET", "name": "encoding_offset", "type": "block", - "multiple": "true", - "multiple_token": "true", + "multiple": true, + "multiple_token": true, "arguments": [ { "name": "encoding", diff --git a/src/help.h b/src/help.h index 4741b9118..7714fc783 100644 --- a/src/help.h +++ b/src/help.h @@ -1,4 +1,4 @@ -/* Automatically generated by utils/generate-command-help.rb, do not edit. */ +/* Automatically generated by ./utils/generate-command-help.rb, do not edit. */ #ifndef __REDIS_HELP_H #define __REDIS_HELP_H @@ -135,7 +135,7 @@ struct commandHelp { 15, "3.2.0" }, { "BITFIELD_RO", - "key GET encoding offset [encoding offset ...]", + "key GET encoding offset [GET encoding offset ...]", "Perform arbitrary bitfield integer operations on strings. Read-only variant of BITFIELD", 15, "6.2.0" }, @@ -255,7 +255,7 @@ struct commandHelp { 8, "2.6.9" }, { "CLIENT TRACKING", - "ON|OFF [REDIRECT client-id] [PREFIX prefix [prefix ...]] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]", + "ON|OFF [REDIRECT client-id] [PREFIX prefix [PREFIX prefix ...]] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]", "Enable or disable server assisted client side caching support", 8, "6.0.0" }, @@ -1025,7 +1025,7 @@ struct commandHelp { 9, "4.0.0" }, { "MODULE LOADEX", - "path [CONFIG name value [name value ...]] [ARGS arg [arg ...]]", + "path [CONFIG name value [CONFIG name value ...]] [ARGS arg [arg ...]]", "Load a module with extended parameters", 9, "7.0.0" }, @@ -1450,12 +1450,12 @@ struct commandHelp { 3, "1.0.0" }, { "SORT", - "key [BY pattern] [LIMIT offset count] [GET pattern [pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]", + "key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]", "Sort the elements in a list, set or sorted set", 0, "1.0.0" }, { "SORT_RO", - "key [BY pattern] [LIMIT offset count] [GET pattern [pattern ...]] [ASC|DESC] [ALPHA]", + "key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA]", "Sort the elements in a list, set or sorted set. Read-only variant of SORT.", 0, "7.0.0" }, diff --git a/utils/generate-command-help.rb b/utils/generate-command-help.rb index 3ef00b3b5..1042ce6d2 100755 --- a/utils/generate-command-help.rb +++ b/utils/generate-command-help.rb @@ -45,7 +45,11 @@ def argument arg name = arg["name"].is_a?(Array) ? arg["name"].join(" ") : arg["name"] end if arg["multiple"] - name = "#{name} [#{name} ...]" + if arg["multiple_token"] + name = "#{name} [#{arg["token"]} #{name} ...]" + else + name = "#{name} [#{name} ...]" + end end if arg["token"] name = [arg["token"], name].compact.join " "