mirror of
https://github.com/redis/redis.git
synced 2026-05-28 04:02:46 -04:00
Repurpose redisCommandArg's name as the unique ID (#11051)
This PR makes sure that "name" is unique for all arguments in the same
level (i.e. all args of a command and all args within a block/oneof).
This means several argument with identical meaning can be referred to together,
but also if someone needs to refer to a specific one, they can use its full path.
In addition, the "display_text" field has been added, to be used by redis.io
in order to render the syntax of the command (for the vast majority it is
identical to "name" but sometimes we want to use a different string
that is not "name")
The "display" field is exposed via COMMAND DOCS and will be present
for every argument, except "oneof" and "block" (which are container
arguments)
Other changes:
1. Make sure we do not have any container arguments ("oneof" or "block")
that contain less than two sub-args (otherwise it doesn't make sense)
2. migrate.json: both AUTH and AUTH2 should not be "optional"
3. arg names cannot contain underscores, and force the usage of hyphens
(most of these were a result of the script that generated the initial json files
from redis.io commands.json).
This commit is contained in:
parent
fc3956e8f4
commit
223046ec9a
62 changed files with 385 additions and 373 deletions
441
src/commands.c
441
src/commands.c
File diff suppressed because it is too large
Load diff
|
|
@ -45,7 +45,7 @@
|
|||
"key_spec_index": 0
|
||||
},
|
||||
{
|
||||
"name": "index",
|
||||
"name": "range",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "index_unit",
|
||||
"name": "unit",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"since": "7.0.0",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
"arguments": [
|
||||
{
|
||||
"token": "GET",
|
||||
"name": "encoding_offset",
|
||||
"name": "get-block",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
"arguments": [
|
||||
{
|
||||
"token": "OVERFLOW",
|
||||
"name": "wrap_sat_fail",
|
||||
"name": "overflow-block",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -91,12 +91,12 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "write_operation",
|
||||
"name": "write-operation",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"token": "SET",
|
||||
"name": "encoding_offset_value",
|
||||
"name": "set-block",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
},
|
||||
{
|
||||
"token": "INCRBY",
|
||||
"name": "encoding_offset_increment",
|
||||
"name": "incrby-block",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -140,4 +140,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
},
|
||||
{
|
||||
"token": "GET",
|
||||
"name": "encoding_offset",
|
||||
"name": "get-block",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"multiple_token": true,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "index",
|
||||
"name": "range",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "end_index",
|
||||
"name": "end-unit-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "index_unit",
|
||||
"name": "unit",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"since": "7.0.0",
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@
|
|||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "ip:port",
|
||||
"name": "old-format",
|
||||
"display": "ip:port",
|
||||
"type": "string",
|
||||
"deprecated_since": "2.8.12"
|
||||
},
|
||||
|
|
@ -63,7 +64,7 @@
|
|||
},
|
||||
{
|
||||
"token": "TYPE",
|
||||
"name": "normal_master_slave_pubsub",
|
||||
"name": "client-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"since": "2.8.12",
|
||||
|
|
@ -105,20 +106,23 @@
|
|||
},
|
||||
{
|
||||
"token": "ADDR",
|
||||
"name": "ip:port",
|
||||
"name": "addr",
|
||||
"display": "ip:port",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"token": "LADDR",
|
||||
"name": "ip:port",
|
||||
"name": "laddr",
|
||||
"display": "ip:port",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"since": "6.2.0"
|
||||
},
|
||||
{
|
||||
"token": "SKIPME",
|
||||
"name": "yes/no",
|
||||
"name": "skipme",
|
||||
"display": "yes/no",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
"arguments": [
|
||||
{
|
||||
"token": "TYPE",
|
||||
"name": "normal_master_replica_pubsub",
|
||||
"name": "client-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"since": "5.0.0",
|
||||
|
|
@ -65,18 +65,12 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"name": "client-id",
|
||||
"token": "ID",
|
||||
"type": "block",
|
||||
"type": "integer",
|
||||
"optional": true,
|
||||
"since": "6.2.0",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "client-id",
|
||||
"type": "integer",
|
||||
"multiple": true
|
||||
}
|
||||
]
|
||||
"multiple": true,
|
||||
"since": "6.2.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "on_off_skip",
|
||||
"name": "action",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "timeout_error",
|
||||
"name": "unblock-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "start-slot_end-slot",
|
||||
"name": "range",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "start-slot_end-slot",
|
||||
"name": "range",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster_bus_port",
|
||||
"name": "cluster-bus-port",
|
||||
"type": "integer",
|
||||
"optional": true,
|
||||
"since": "4.0.0"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "hard_soft",
|
||||
"name": "reset-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -25,17 +25,20 @@
|
|||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "node-id",
|
||||
"name": "importing",
|
||||
"display": "node-id",
|
||||
"type": "string",
|
||||
"token": "IMPORTING"
|
||||
},
|
||||
{
|
||||
"name": "node-id",
|
||||
"name": "migrating",
|
||||
"display": "node-id",
|
||||
"type": "string",
|
||||
"token": "MIGRATING"
|
||||
},
|
||||
{
|
||||
"name": "node-id",
|
||||
"name": "node",
|
||||
"display": "node-id",
|
||||
"type": "string",
|
||||
"token": "NODE"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,14 +22,8 @@
|
|||
"arguments": [
|
||||
{
|
||||
"name": "parameter",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
{
|
||||
"name": "parameter",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
"type": "string",
|
||||
"multiple": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "parameter_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "async",
|
||||
"name": "flush-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "async",
|
||||
"name": "flush-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "async",
|
||||
"name": "flush-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
"since": "6.2.0"
|
||||
},
|
||||
{
|
||||
"name": "longitude_latitude_member",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@
|
|||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -183,14 +183,16 @@
|
|||
},
|
||||
{
|
||||
"token": "STORE",
|
||||
"name": "key",
|
||||
"name": "storekey",
|
||||
"display": "key",
|
||||
"type": "key",
|
||||
"key_spec_index": 1,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"token": "STOREDIST",
|
||||
"name": "key",
|
||||
"name": "storedistkey",
|
||||
"display": "key",
|
||||
"type": "key",
|
||||
"key_spec_index": 2,
|
||||
"optional": true
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -172,14 +172,16 @@
|
|||
},
|
||||
{
|
||||
"token": "STORE",
|
||||
"name": "key",
|
||||
"name": "storekey",
|
||||
"display": "key",
|
||||
"type": "key",
|
||||
"key_spec_index": 1,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"token": "STOREDIST",
|
||||
"name": "key",
|
||||
"name": "storedistkey",
|
||||
"display": "key",
|
||||
"type": "key",
|
||||
"key_spec_index": 2,
|
||||
"optional": true
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
},
|
||||
{
|
||||
"token": "FROMLONLAT",
|
||||
"name": "longitude_latitude",
|
||||
"name": "fromlonlat",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -203,4 +203,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
},
|
||||
{
|
||||
"token": "FROMLONLAT",
|
||||
"name": "longitude_latitude",
|
||||
"name": "fromlonlat",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -190,7 +190,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"name": "count-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -215,4 +215,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
},
|
||||
{
|
||||
"token": "AUTH",
|
||||
"name": "username_password",
|
||||
"name": "auth",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
"key_spec_index": 0
|
||||
},
|
||||
{
|
||||
"name": "field_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
"key_spec_index": 0
|
||||
},
|
||||
{
|
||||
"name": "field_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
},
|
||||
{
|
||||
"token": "MINMATCHLEN",
|
||||
"name": "len",
|
||||
"name": "min-match-len",
|
||||
"type": "integer",
|
||||
"optional": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "key_or_empty_string",
|
||||
"name": "key-selector",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
"key_spec_index": 0
|
||||
},
|
||||
{
|
||||
"name": "empty_string",
|
||||
"name": "empty-string",
|
||||
"type": "pure-token",
|
||||
"token": "\"\""
|
||||
}
|
||||
|
|
@ -131,16 +131,15 @@
|
|||
"arguments": [
|
||||
{
|
||||
"token": "AUTH",
|
||||
"name": "password",
|
||||
"name": "auth",
|
||||
"display": "password",
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"since": "4.0.7"
|
||||
},
|
||||
{
|
||||
"token": "AUTH2",
|
||||
"name": "username_password",
|
||||
"name": "auth2",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"since": "6.0.0",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
@ -157,7 +156,8 @@
|
|||
},
|
||||
{
|
||||
"token": "KEYS",
|
||||
"name": "key",
|
||||
"name": "keys",
|
||||
"display": "key",
|
||||
"type": "key",
|
||||
"key_spec_index": 1,
|
||||
"optional": true,
|
||||
|
|
@ -166,4 +166,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,16 +39,10 @@
|
|||
{
|
||||
"name": "args",
|
||||
"token": "ARGS",
|
||||
"type": "block",
|
||||
"type": "string",
|
||||
"multiple": true,
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
{
|
||||
"name": "arg",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
"optional": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -16,14 +16,8 @@
|
|||
"arguments": [
|
||||
{
|
||||
"name": "pattern",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
{
|
||||
"name": "pattern",
|
||||
"type": "pattern"
|
||||
}
|
||||
]
|
||||
"type": "pattern",
|
||||
"multiple": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "async",
|
||||
"name": "flush-type",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"since": "6.2.0",
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name":"set_or_get",
|
||||
"name":"action",
|
||||
"type":"oneof",
|
||||
"arguments":[
|
||||
{
|
||||
"name":"set_param_value",
|
||||
"name":"set",
|
||||
"token":"SET",
|
||||
"type":"block",
|
||||
"multiple":true,
|
||||
|
|
@ -36,7 +36,8 @@
|
|||
{
|
||||
"token":"GET",
|
||||
"multiple":true,
|
||||
"name":"parameter",
|
||||
"name":"get",
|
||||
"display":"parameter",
|
||||
"type":"string"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "parameter_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "option_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "nosave_save",
|
||||
"name": "save-selector",
|
||||
"type": "oneof",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -71,14 +71,15 @@
|
|||
},
|
||||
{
|
||||
"token": "BY",
|
||||
"name": "pattern",
|
||||
"name": "by-pattern",
|
||||
"display": "pattern",
|
||||
"type": "pattern",
|
||||
"key_spec_index": 1,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -94,7 +95,8 @@
|
|||
},
|
||||
{
|
||||
"token": "GET",
|
||||
"name": "pattern",
|
||||
"name": "get-pattern",
|
||||
"display": "pattern",
|
||||
"key_spec_index": 1,
|
||||
"type": "pattern",
|
||||
"optional": true,
|
||||
|
|
|
|||
|
|
@ -57,14 +57,15 @@
|
|||
},
|
||||
{
|
||||
"token": "BY",
|
||||
"name": "pattern",
|
||||
"name": "by-pattern",
|
||||
"display": "pattern",
|
||||
"type": "pattern",
|
||||
"key_spec_index": 1,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
@ -80,7 +81,8 @@
|
|||
},
|
||||
{
|
||||
"token": "GET",
|
||||
"name": "pattern",
|
||||
"name": "get-pattern",
|
||||
"display": "pattern",
|
||||
"key_spec_index": 1,
|
||||
"type": "pattern",
|
||||
"optional": true,
|
||||
|
|
|
|||
|
|
@ -114,22 +114,22 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "id_or_auto",
|
||||
"name": "id-selector",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "auto_id",
|
||||
"name": "auto-id",
|
||||
"type": "pure-token",
|
||||
"token": "*"
|
||||
},
|
||||
{
|
||||
"name": "ID",
|
||||
"name": "id",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "field_value",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@
|
|||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"name": "lastid",
|
||||
"token": "LASTID",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@
|
|||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"name": "id-selector",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "ID",
|
||||
"name": "id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "new_id",
|
||||
"name": "new-id",
|
||||
"type": "pure-token",
|
||||
"token": "$"
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
},
|
||||
{
|
||||
"token": "ENTRIESREAD",
|
||||
"name": "entries_read",
|
||||
"name": "entries-read",
|
||||
"type": "integer",
|
||||
"optional": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,22 +50,23 @@
|
|||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"name": "id-selector",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "ID",
|
||||
"name": "id",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "new_id",
|
||||
"name": "new-id",
|
||||
"type": "pure-token",
|
||||
"token": "$"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "entries_read",
|
||||
"name": "entriesread",
|
||||
"display": "entries-read",
|
||||
"token": "ENTRIESREAD",
|
||||
"type": "integer",
|
||||
"optional": true
|
||||
|
|
|
|||
|
|
@ -50,11 +50,15 @@
|
|||
"key_spec_index": 0
|
||||
},
|
||||
{
|
||||
"name": "full",
|
||||
"token": "FULL",
|
||||
"name": "full-block",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
{
|
||||
"name": "full",
|
||||
"token": "FULL",
|
||||
"type": "pure-token"
|
||||
},
|
||||
{
|
||||
"token": "COUNT",
|
||||
"name": "count",
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
"arguments": [
|
||||
{
|
||||
"token": "GROUP",
|
||||
"name": "group_consumer",
|
||||
"name": "group-block",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@
|
|||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "entries_added",
|
||||
"name": "entries-added",
|
||||
"token": "ENTRIESADDED",
|
||||
"type": "integer",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "max_deleted_entry_id",
|
||||
"name": "max-deleted-id",
|
||||
"token": "MAXDELETEDID",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@
|
|||
"since": "3.0.2"
|
||||
},
|
||||
{
|
||||
"name": "score_member",
|
||||
"name": "data",
|
||||
"type": "block",
|
||||
"multiple": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"since": "6.2.0",
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
},
|
||||
{
|
||||
"token": "LIMIT",
|
||||
"name": "offset_count",
|
||||
"name": "limit",
|
||||
"type": "block",
|
||||
"optional": true,
|
||||
"arguments": [
|
||||
|
|
|
|||
|
|
@ -1927,6 +1927,7 @@ static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args
|
|||
if (arg->summary) realargs[j].summary = zstrdup(arg->summary);
|
||||
if (arg->since) realargs[j].since = zstrdup(arg->since);
|
||||
if (arg->deprecated_since) realargs[j].deprecated_since = zstrdup(arg->deprecated_since);
|
||||
if (arg->display_text) realargs[j].display_text = zstrdup(arg->display_text);
|
||||
realargs[j].flags = moduleConvertArgFlags(arg->flags);
|
||||
if (arg->subargs) realargs[j].subargs = moduleCopyCommandArgs(arg->subargs, version);
|
||||
}
|
||||
|
|
@ -11046,6 +11047,7 @@ void moduleFreeArgs(struct redisCommandArg *args, int num_args) {
|
|||
zfree((char *)args[j].summary);
|
||||
zfree((char *)args[j].since);
|
||||
zfree((char *)args[j].deprecated_since);
|
||||
zfree((char *)args[j].display_text);
|
||||
|
||||
if (args[j].subargs) {
|
||||
moduleFreeArgs(args[j].subargs, args[j].num_args);
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ typedef struct RedisModuleCommandArg {
|
|||
int flags; /* The REDISMODULE_CMD_ARG_* macros. */
|
||||
const char *deprecated_since;
|
||||
struct RedisModuleCommandArg *subargs;
|
||||
const char *display_text;
|
||||
} RedisModuleCommandArg;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
10
src/server.c
10
src/server.c
|
|
@ -4514,6 +4514,7 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg
|
|||
addReplyArrayLen(c, num_args);
|
||||
for (int j = 0; j<num_args; j++) {
|
||||
/* Count our reply len so we don't have to use deferred reply. */
|
||||
int has_display_text = 1;
|
||||
long maplen = 2;
|
||||
if (args[j].key_spec_index != -1) maplen++;
|
||||
if (args[j].token) maplen++;
|
||||
|
|
@ -4521,8 +4522,11 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg
|
|||
if (args[j].since) maplen++;
|
||||
if (args[j].deprecated_since) maplen++;
|
||||
if (args[j].flags) maplen++;
|
||||
if (args[j].type == ARG_TYPE_ONEOF || args[j].type == ARG_TYPE_BLOCK)
|
||||
if (args[j].type == ARG_TYPE_ONEOF || args[j].type == ARG_TYPE_BLOCK) {
|
||||
has_display_text = 0;
|
||||
maplen++;
|
||||
}
|
||||
if (has_display_text) maplen++;
|
||||
addReplyMapLen(c, maplen);
|
||||
|
||||
addReplyBulkCString(c, "name");
|
||||
|
|
@ -4531,6 +4535,10 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg
|
|||
addReplyBulkCString(c, "type");
|
||||
addReplyBulkCString(c, ARG_TYPE_STR[args[j].type]);
|
||||
|
||||
if (has_display_text) {
|
||||
addReplyBulkCString(c, "display_text");
|
||||
addReplyBulkCString(c, args[j].display_text ? args[j].display_text : args[j].name);
|
||||
}
|
||||
if (args[j].key_spec_index != -1) {
|
||||
addReplyBulkCString(c, "key_spec_index");
|
||||
addReplyLongLong(c, args[j].key_spec_index);
|
||||
|
|
|
|||
|
|
@ -1985,7 +1985,7 @@ typedef struct {
|
|||
* 2. keynum: there's an arg that contains the number of key args somewhere before the keys themselves
|
||||
*/
|
||||
|
||||
/* Must be synced with generate-command-code.py */
|
||||
/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecBeginSearchType */
|
||||
typedef enum {
|
||||
KSPEC_BS_INVALID = 0, /* Must be 0 */
|
||||
KSPEC_BS_UNKNOWN,
|
||||
|
|
@ -1993,7 +1993,7 @@ typedef enum {
|
|||
KSPEC_BS_KEYWORD
|
||||
} kspec_bs_type;
|
||||
|
||||
/* Must be synced with generate-command-code.py */
|
||||
/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecFindKeysType */
|
||||
typedef enum {
|
||||
KSPEC_FK_INVALID = 0, /* Must be 0 */
|
||||
KSPEC_FK_UNKNOWN,
|
||||
|
|
@ -2001,6 +2001,7 @@ typedef enum {
|
|||
KSPEC_FK_KEYNUM
|
||||
} kspec_fk_type;
|
||||
|
||||
/* WARNING! This struct must match RedisModuleCommandKeySpec */
|
||||
typedef struct {
|
||||
/* Declarative data */
|
||||
const char *notes;
|
||||
|
|
@ -2068,6 +2069,7 @@ typedef enum {
|
|||
#define CMD_ARG_MULTIPLE (1<<1)
|
||||
#define CMD_ARG_MULTIPLE_TOKEN (1<<2)
|
||||
|
||||
/* WARNING! This struct must match RedisModuleCommandArg */
|
||||
typedef struct redisCommandArg {
|
||||
const char *name;
|
||||
redisCommandArgType type;
|
||||
|
|
@ -2078,6 +2080,7 @@ typedef struct redisCommandArg {
|
|||
int flags;
|
||||
const char *deprecated_since;
|
||||
struct redisCommandArg *subargs;
|
||||
const char *display_text;
|
||||
/* runtime populated data */
|
||||
int num_args;
|
||||
} redisCommandArg;
|
||||
|
|
@ -2107,6 +2110,7 @@ typedef enum {
|
|||
RESP3_NULL,
|
||||
} redisCommandRESP3Type;
|
||||
|
||||
/* WARNING! This struct must match RedisModuleCommandHistoryEntry */
|
||||
typedef struct {
|
||||
const char *since;
|
||||
const char *changes;
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
{
|
||||
.name = "threshold",
|
||||
.type = REDISMODULE_ARG_TYPE_STRING,
|
||||
.display_text = "threshold" /* Just for coverage, doesn't have a visible effect */
|
||||
},
|
||||
{
|
||||
.name = "count",
|
||||
|
|
@ -116,11 +117,11 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
}
|
||||
},
|
||||
{
|
||||
.name = "id_or_auto",
|
||||
.name = "id-selector",
|
||||
.type = REDISMODULE_ARG_TYPE_ONEOF,
|
||||
.subargs = (RedisModuleCommandArg[]){
|
||||
{
|
||||
.name = "auto_id",
|
||||
.name = "auto-id",
|
||||
.type = REDISMODULE_ARG_TYPE_PURE_TOKEN,
|
||||
.token = "*"
|
||||
},
|
||||
|
|
@ -132,7 +133,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
}
|
||||
},
|
||||
{
|
||||
.name = "field_value",
|
||||
.name = "data",
|
||||
.type = REDISMODULE_ARG_TYPE_BLOCK,
|
||||
.flags = REDISMODULE_CMD_ARG_MULTIPLE,
|
||||
.subargs = (RedisModuleCommandArg[]){
|
||||
|
|
|
|||
|
|
@ -175,18 +175,36 @@ class KeySpec(object):
|
|||
)
|
||||
|
||||
|
||||
def verify_no_dup_names(container_fullname, args):
|
||||
name_list = [arg.name for arg in args]
|
||||
name_set = set(name_list)
|
||||
if len(name_list) != len(name_set):
|
||||
print("{}: Dup argument names: {}".format(container_fullname, name_list))
|
||||
exit(1)
|
||||
|
||||
|
||||
class Argument(object):
|
||||
def __init__(self, parent_name, desc):
|
||||
self.parent_name = parent_name
|
||||
self.desc = desc
|
||||
self.name = self.desc["name"].lower()
|
||||
if "_" in self.name:
|
||||
print("{}: name ({}) should not contain underscores".format(self.fullname(), self.name))
|
||||
exit(1)
|
||||
self.type = self.desc["type"]
|
||||
self.key_spec_index = self.desc.get("key_spec_index", None)
|
||||
self.parent_name = parent_name
|
||||
self.subargs = []
|
||||
self.subargs_name = None
|
||||
if self.type in ["oneof", "block"]:
|
||||
self.display = None
|
||||
for subdesc in self.desc["arguments"]:
|
||||
self.subargs.append(Argument(self.fullname(), subdesc))
|
||||
if len(self.subargs) < 2:
|
||||
print("{}: oneof or block arg contains less than two subargs".format(self.fullname()))
|
||||
exit(1)
|
||||
verify_no_dup_names(self.fullname(), self.subargs)
|
||||
else:
|
||||
self.display = self.desc.get("display")
|
||||
|
||||
def fullname(self):
|
||||
return ("%s %s" % (self.parent_name, self.name)).replace("-", "_")
|
||||
|
|
@ -226,6 +244,8 @@ class Argument(object):
|
|||
)
|
||||
if "deprecated_since" in self.desc:
|
||||
s += ",.deprecated_since=\"%s\"" % self.desc["deprecated_since"]
|
||||
if "display" in self.desc:
|
||||
s += ",.display_text=\"%s\"" % self.desc["display"].lower()
|
||||
if self.subargs:
|
||||
s += ",.subargs=%s" % self.subarg_table_name()
|
||||
|
||||
|
|
@ -253,7 +273,9 @@ class Command(object):
|
|||
self.subcommands = []
|
||||
self.args = []
|
||||
for arg_desc in self.desc.get("arguments", []):
|
||||
self.args.append(Argument(self.fullname(), arg_desc))
|
||||
arg = Argument(self.fullname(), arg_desc)
|
||||
self.args.append(arg)
|
||||
verify_no_dup_names(self.fullname(), self.args)
|
||||
|
||||
def fullname(self):
|
||||
return self.name.replace("-", "_").replace(":", "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue