]>
Commit | Line | Data |
---|---|---|
5397f2b5 TH |
1 | |
2 | // Auto-generated, do not edit. | |
3 | ||
4 | #include <stdio.h> | |
5 | #include <string.h> | |
6 | ||
7 | /* | |
8 | * List command groups. | |
9 | */ | |
10 | ||
11 | #define GROUPS \ | |
12 | G(UNKNOWN, "unknown") \ | |
13 | G(SET, "set") \ | |
14 | G(LIST, "list") \ | |
15 | G(HASH, "hash") \ | |
16 | G(GENERIC, "generic") \ | |
17 | G(PUBSUB, "pubsub") \ | |
18 | G(STRING, "string") \ | |
19 | G(SERVER, "server") \ | |
20 | G(CONNECTION, "connection") \ | |
21 | G(TRANSACTIONS, "transactions") \ | |
22 | G(SORTED_SET, "sorted_set") | |
23 | ||
24 | /* | |
25 | * Command group types. | |
26 | */ | |
27 | ||
28 | typedef enum { | |
29 | #define G(GROUP, _) COMMAND_GROUP_##GROUP, | |
30 | GROUPS | |
31 | #undef G | |
32 | COMMAND_GROUP_LENGTH | |
33 | } command_group_type_t; | |
34 | ||
35 | /* | |
36 | * Command group type names. | |
37 | */ | |
38 | ||
39 | static char *command_group_type_names[] = { | |
40 | #define G(_, STR) STR, | |
41 | GROUPS | |
42 | #undef G | |
43 | }; | |
44 | ||
45 | /* | |
46 | * Command help struct. | |
47 | */ | |
48 | ||
49 | struct command_help { | |
50 | char *name; | |
51 | char *params; | |
52 | char *summary; | |
53 | command_group_type_t group; | |
54 | char *since; | |
55 | } command_help[] = { | |
56 | { "APPEND" | |
57 | , "key value" | |
58 | , "Append a value to a key" | |
59 | , COMMAND_GROUP_STRING | |
60 | , "1.3.3" } | |
61 | ||
62 | , { "AUTH" | |
63 | , "password" | |
64 | , "Authenticate to the server" | |
65 | , COMMAND_GROUP_CONNECTION | |
66 | , "0.08" } | |
67 | ||
68 | , { "BGREWRITEAOF" | |
69 | , "-" | |
70 | , "Asynchronously rewrite the append-only file" | |
71 | , COMMAND_GROUP_SERVER | |
72 | , "1.07" } | |
73 | ||
74 | , { "BGSAVE" | |
75 | , "-" | |
76 | , "Asynchronously save the dataset to disk" | |
77 | , COMMAND_GROUP_SERVER | |
78 | , "0.07" } | |
79 | ||
80 | , { "BLPOP" | |
81 | , "(key)+ timeout" | |
82 | , "Remove and get the first element in a list, or block until one is available" | |
83 | , COMMAND_GROUP_LIST | |
84 | , "1.3.1" } | |
85 | ||
86 | , { "BRPOP" | |
87 | , "(key)+ timeout" | |
88 | , "Remove and get the last element in a list, or block until one is available" | |
89 | , COMMAND_GROUP_LIST | |
90 | , "1.3.1" } | |
91 | ||
92 | , { "CONFIG GET" | |
93 | , "parameter" | |
94 | , "Get the value of a configuration parameter" | |
95 | , COMMAND_GROUP_SERVER | |
96 | , "2.0" } | |
97 | ||
98 | , { "CONFIG SET" | |
99 | , "parameter value" | |
100 | , "Set a configuration parameter to the given value" | |
101 | , COMMAND_GROUP_SERVER | |
102 | , "2.0" } | |
103 | ||
104 | , { "DBSIZE" | |
105 | , "-" | |
106 | , "Return the number of keys in the selected database" | |
107 | , COMMAND_GROUP_SERVER | |
108 | , "0.07" } | |
109 | ||
110 | , { "DEBUG OBJECT" | |
111 | , "key" | |
112 | , "Get debugging information about a key" | |
113 | , COMMAND_GROUP_SERVER | |
114 | , "0.101" } | |
115 | ||
116 | , { "DEBUG SEGFAULT" | |
117 | , "-" | |
118 | , "Make the server crash" | |
119 | , COMMAND_GROUP_SERVER | |
120 | , "0.101" } | |
121 | ||
122 | , { "DECR" | |
123 | , "key decrement" | |
124 | , "Decrement the integer value of a key by one" | |
125 | , COMMAND_GROUP_STRING | |
126 | , "0.07" } | |
127 | ||
128 | , { "DECRBY" | |
129 | , "key decrement" | |
130 | , "Decrement the integer value of a key by the given number" | |
131 | , COMMAND_GROUP_STRING | |
132 | , "0.07" } | |
133 | ||
134 | , { "DEL" | |
135 | , "(key)+" | |
136 | , "Delete a key" | |
137 | , COMMAND_GROUP_GENERIC | |
138 | , "0.07" } | |
139 | ||
140 | , { "DISCARD" | |
141 | , "-" | |
142 | , "Discard all commands issued after MULTI" | |
143 | , COMMAND_GROUP_TRANSACTIONS | |
144 | , "1.3.3" } | |
145 | ||
146 | , { "ECHO" | |
147 | , "message" | |
148 | , "Echo the given string" | |
149 | , COMMAND_GROUP_CONNECTION | |
150 | , "0.07" } | |
151 | ||
152 | , { "EXEC" | |
153 | , "-" | |
154 | , "Execute all commands issued after MULTI" | |
155 | , COMMAND_GROUP_TRANSACTIONS | |
156 | , "1.1.95" } | |
157 | ||
158 | , { "EXISTS" | |
159 | , "key" | |
160 | , "Determine if a key exists" | |
161 | , COMMAND_GROUP_SERVER | |
162 | , "0.07" } | |
163 | ||
164 | , { "EXPIRE" | |
165 | , "key seconds" | |
166 | , "Set a key's time to live in seconds" | |
167 | , COMMAND_GROUP_GENERIC | |
168 | , "0.09" } | |
169 | ||
170 | , { "EXPIREAT" | |
171 | , "key timestamp" | |
172 | , "Set the expiration for a key as a UNIX timestamp" | |
173 | , COMMAND_GROUP_GENERIC | |
174 | , "1.1" } | |
175 | ||
176 | , { "FLUSHALL" | |
177 | , "-" | |
178 | , "Remove all keys from all databases" | |
179 | , COMMAND_GROUP_SERVER | |
180 | , "0.07" } | |
181 | ||
182 | , { "FLUSHDB" | |
183 | , "-" | |
184 | , "Remove all keys from the current database" | |
185 | , COMMAND_GROUP_SERVER | |
186 | , "0.07" } | |
187 | ||
188 | , { "GET" | |
189 | , "key" | |
190 | , "Get the value of a key" | |
191 | , COMMAND_GROUP_STRING | |
192 | , "0.07" } | |
193 | ||
194 | , { "GETSET" | |
195 | , "key value" | |
196 | , "Set the string value of a key and return its old value" | |
197 | , COMMAND_GROUP_STRING | |
198 | , "0.091" } | |
199 | ||
200 | , { "HDEL" | |
201 | , "key field" | |
202 | , "Delete a hash field" | |
203 | , COMMAND_GROUP_HASH | |
204 | , "1.3.10" } | |
205 | ||
206 | , { "HEXISTS" | |
207 | , "key field" | |
208 | , "Determine if a hash field exists" | |
209 | , COMMAND_GROUP_HASH | |
210 | , "1.3.10" } | |
211 | ||
212 | , { "HGET" | |
213 | , "key field" | |
214 | , "Get the value of a hash field" | |
215 | , COMMAND_GROUP_HASH | |
216 | , "1.3.10" } | |
217 | ||
218 | , { "HGETALL" | |
219 | , "key" | |
220 | , "Get all the fields and values in a hash" | |
221 | , COMMAND_GROUP_HASH | |
222 | , "1.3.10" } | |
223 | ||
224 | , { "HINCRBY" | |
225 | , "key field increment" | |
226 | , "Increment the integer value of a hash field by the given number" | |
227 | , COMMAND_GROUP_HASH | |
228 | , "1.3.10" } | |
229 | ||
230 | , { "HKEYS" | |
231 | , "key" | |
232 | , "Get all the fields in a hash" | |
233 | , COMMAND_GROUP_HASH | |
234 | , "1.3.10" } | |
235 | ||
236 | , { "HLEN" | |
237 | , "key" | |
238 | , "Get the number of fields in a hash" | |
239 | , COMMAND_GROUP_HASH | |
240 | , "1.3.10" } | |
241 | ||
242 | , { "HMGET" | |
243 | , "key (field)+" | |
244 | , "Get the values of all the given hash fields" | |
245 | , COMMAND_GROUP_HASH | |
246 | , "1.3.10" } | |
247 | ||
248 | , { "HMSET" | |
249 | , "key (field value)+" | |
250 | , "Set multiple hash fields to multiple values" | |
251 | , COMMAND_GROUP_HASH | |
252 | , "1.3.8" } | |
253 | ||
254 | , { "HSET" | |
255 | , "key field value" | |
256 | , "Set the string value of a hash field" | |
257 | , COMMAND_GROUP_HASH | |
258 | , "1.3.10" } | |
259 | ||
260 | , { "HSETNX" | |
261 | , "key field value" | |
262 | , "Set the value of a hash field, only if the field does not exist" | |
263 | , COMMAND_GROUP_HASH | |
264 | , "1.3.8" } | |
265 | ||
266 | , { "HVALS" | |
267 | , "key" | |
268 | , "Get all the values in a hash" | |
269 | , COMMAND_GROUP_HASH | |
270 | , "1.3.10" } | |
271 | ||
272 | , { "INCR" | |
273 | , "key" | |
274 | , "Increment the integer value of a key by one" | |
275 | , COMMAND_GROUP_STRING | |
276 | , "0.07" } | |
277 | ||
278 | , { "INCRBY" | |
279 | , "key increment" | |
280 | , "Increment the integer value of a key by the given number" | |
281 | , COMMAND_GROUP_STRING | |
282 | , "0.07" } | |
283 | ||
284 | , { "INFO" | |
285 | , "-" | |
286 | , "Get information and statistics about the server" | |
287 | , COMMAND_GROUP_SERVER | |
288 | , "0.07" } | |
289 | ||
290 | , { "KEYS" | |
291 | , "pattern" | |
292 | , "Find all keys matching the given pattern" | |
293 | , COMMAND_GROUP_GENERIC | |
294 | , "0.07" } | |
295 | ||
296 | , { "LASTSAVE" | |
297 | , "-" | |
298 | , "Get the UNIX time stamp of the last successful save to disk" | |
299 | , COMMAND_GROUP_SERVER | |
300 | , "0.07" } | |
301 | ||
302 | , { "LINDEX" | |
303 | , "key index" | |
304 | , "Get an element from a list by its index" | |
305 | , COMMAND_GROUP_LIST | |
306 | , "0.07" } | |
307 | ||
308 | , { "LINSERT" | |
309 | , "key BEFORE|AFTER pivot value" | |
310 | , "Insert an element before or after another element in a list" | |
311 | , COMMAND_GROUP_LIST | |
312 | , "2.1.1" } | |
313 | ||
314 | , { "LLEN" | |
315 | , "key" | |
316 | , "Get the length of a list" | |
317 | , COMMAND_GROUP_LIST | |
318 | , "0.07" } | |
319 | ||
320 | , { "LPOP" | |
321 | , "key" | |
322 | , "Remove and get the first element in a list" | |
323 | , COMMAND_GROUP_LIST | |
324 | , "0.07" } | |
325 | ||
326 | , { "LPUSH" | |
327 | , "key value" | |
328 | , "Prepend a value to a list" | |
329 | , COMMAND_GROUP_LIST | |
330 | , "0.07" } | |
331 | ||
332 | , { "LPUSHX" | |
333 | , "key value" | |
334 | , "Prepend a value to a list, only if the list exists" | |
335 | , COMMAND_GROUP_LIST | |
336 | , "2.1.1" } | |
337 | ||
338 | , { "LRANGE" | |
339 | , "key start stop" | |
340 | , "Get a range of elements from a list" | |
341 | , COMMAND_GROUP_LIST | |
342 | , "0.07" } | |
343 | ||
344 | , { "LREM" | |
345 | , "key count value" | |
346 | , "Remove elements from a list" | |
347 | , COMMAND_GROUP_LIST | |
348 | , "0.07" } | |
349 | ||
350 | , { "LSET" | |
351 | , "key index value" | |
352 | , "Set the value of an element in a list by its index" | |
353 | , COMMAND_GROUP_LIST | |
354 | , "0.07" } | |
355 | ||
356 | , { "LTRIM" | |
357 | , "key start stop" | |
358 | , "Trim a list to the specified range" | |
359 | , COMMAND_GROUP_LIST | |
360 | , "0.07" } | |
361 | ||
362 | , { "MGET" | |
363 | , "(key)+" | |
364 | , "Get the values of all the given keys" | |
365 | , COMMAND_GROUP_STRING | |
366 | , "0.07" } | |
367 | ||
368 | , { "MONITOR" | |
369 | , "-" | |
370 | , "Listen for all requests received by the server in real time" | |
371 | , COMMAND_GROUP_SERVER | |
372 | , "0.07" } | |
373 | ||
374 | , { "MOVE" | |
375 | , "key db" | |
376 | , "Move a key to another database" | |
377 | , COMMAND_GROUP_GENERIC | |
378 | , "0.07" } | |
379 | ||
380 | , { "MSET" | |
381 | , "(key value)+" | |
382 | , "Set multiple keys to multiple values" | |
383 | , COMMAND_GROUP_STRING | |
384 | , "1.001" } | |
385 | ||
386 | , { "MSETNX" | |
387 | , "(key value)+" | |
388 | , "Set multiple keys to multiple values, only if none of the keys exist" | |
389 | , COMMAND_GROUP_STRING | |
390 | , "1.001" } | |
391 | ||
392 | , { "MULTI" | |
393 | , "-" | |
394 | , "Mark the start of a transaction block" | |
395 | , COMMAND_GROUP_TRANSACTIONS | |
396 | , "1.1.95" } | |
397 | ||
398 | , { "PERSIST" | |
399 | , "key" | |
400 | , "Remove the expiration from a key" | |
401 | , COMMAND_GROUP_GENERIC | |
402 | , "2.1.2" } | |
403 | ||
404 | , { "PING" | |
405 | , "-" | |
406 | , "Ping the server" | |
407 | , COMMAND_GROUP_CONNECTION | |
408 | , "0.07" } | |
409 | ||
410 | , { "PSUBSCRIBE" | |
411 | , "pattern" | |
412 | , "Listen for messages published to channels matching the given patterns" | |
413 | , COMMAND_GROUP_PUBSUB | |
414 | , "1.3.8" } | |
415 | ||
416 | , { "PUBLISH" | |
417 | , "channel message" | |
418 | , "Post a message to a channel" | |
419 | , COMMAND_GROUP_PUBSUB | |
420 | , "1.3.8" } | |
421 | ||
422 | , { "PUNSUBSCRIBE" | |
423 | , "(pattern)*" | |
424 | , "Stop listening for messages posted to channels matching the given patterns" | |
425 | , COMMAND_GROUP_PUBSUB | |
426 | , "1.3.8" } | |
427 | ||
428 | , { "QUIT" | |
429 | , "-" | |
430 | , "Close the connection" | |
431 | , COMMAND_GROUP_CONNECTION | |
432 | , "0.07" } | |
433 | ||
434 | , { "RANDOMKEY" | |
435 | , "-" | |
436 | , "Return a random key from the keyspace" | |
437 | , COMMAND_GROUP_GENERIC | |
438 | , "0.07" } | |
439 | ||
440 | , { "RENAME" | |
441 | , "old new" | |
442 | , "Rename a key" | |
443 | , COMMAND_GROUP_GENERIC | |
444 | , "0.07" } | |
445 | ||
446 | , { "RENAMENX" | |
447 | , "old new" | |
448 | , "Rename a key, only if the new key does not exist" | |
449 | , COMMAND_GROUP_GENERIC | |
450 | , "0.07" } | |
451 | ||
452 | , { "RPOP" | |
453 | , "key" | |
454 | , "Remove and get the last element in a list" | |
455 | , COMMAND_GROUP_LIST | |
456 | , "0.07" } | |
457 | ||
458 | , { "RPOPLPUSH" | |
459 | , "source destination" | |
460 | , "Remove the last element in a list, append it to another list and return it" | |
461 | , COMMAND_GROUP_LIST | |
462 | , "1.1" } | |
463 | ||
464 | , { "RPUSH" | |
465 | , "key value" | |
466 | , "Append a value to a list" | |
467 | , COMMAND_GROUP_LIST | |
468 | , "0.07" } | |
469 | ||
470 | , { "RPUSHX" | |
471 | , "key value" | |
472 | , "Append a value to a list, only if the list exists" | |
473 | , COMMAND_GROUP_LIST | |
474 | , "2.1.1" } | |
475 | ||
476 | , { "SADD" | |
477 | , "key member" | |
478 | , "Add a member to a set" | |
479 | , COMMAND_GROUP_SET | |
480 | , "0.07" } | |
481 | ||
482 | , { "SAVE" | |
483 | , "-" | |
484 | , "Synchronously save the dataset to disk" | |
485 | , COMMAND_GROUP_SERVER | |
486 | , "0.07" } | |
487 | ||
488 | , { "SCARD" | |
489 | , "key" | |
490 | , "Get the number of members in a set" | |
491 | , COMMAND_GROUP_SET | |
492 | , "0.07" } | |
493 | ||
494 | , { "SDIFF" | |
495 | , "(key)+" | |
496 | , "Subtract multiple sets" | |
497 | , COMMAND_GROUP_SET | |
498 | , "0.100" } | |
499 | ||
500 | , { "SDIFFSTORE" | |
501 | , "destination (key)+" | |
502 | , "Subtract multiple sets and store the resulting set in a key" | |
503 | , COMMAND_GROUP_SET | |
504 | , "0.100" } | |
505 | ||
506 | , { "SELECT" | |
507 | , "index" | |
508 | , "Change the selected database for the current connection" | |
509 | , COMMAND_GROUP_CONNECTION | |
510 | , "0.07" } | |
511 | ||
512 | , { "SET" | |
513 | , "key value" | |
514 | , "Set the string value of a key" | |
515 | , COMMAND_GROUP_STRING | |
516 | , "0.07" } | |
517 | ||
518 | , { "SETEX" | |
519 | , "key timestamp value" | |
520 | , "Set the value and expiration of a key" | |
521 | , COMMAND_GROUP_STRING | |
522 | , "1.3.10" } | |
523 | ||
524 | , { "SETNX" | |
525 | , "key value" | |
526 | , "Set the value of a key, only if the key does not exist" | |
527 | , COMMAND_GROUP_STRING | |
528 | , "0.07" } | |
529 | ||
530 | , { "SHUTDOWN" | |
531 | , "-" | |
532 | , "Synchronously save the dataset to disk and then shut down the server" | |
533 | , COMMAND_GROUP_SERVER | |
534 | , "0.07" } | |
535 | ||
536 | , { "SINTER" | |
537 | , "(key)+" | |
538 | , "Intersect multiple sets" | |
539 | , COMMAND_GROUP_SET | |
540 | , "0.07" } | |
541 | ||
542 | , { "SINTERSTORE" | |
543 | , "destination (key)+" | |
544 | , "Intersect multiple sets and store the resulting set in a key" | |
545 | , COMMAND_GROUP_SET | |
546 | , "0.07" } | |
547 | ||
548 | , { "SISMEMBER" | |
549 | , "key member" | |
550 | , "Determine if a given value is a member of a set" | |
551 | , COMMAND_GROUP_SET | |
552 | , "0.07" } | |
553 | ||
554 | , { "SLAVEOF" | |
555 | , "host port" | |
556 | , "Make the server a slave of another instance, or promote it as master" | |
557 | , COMMAND_GROUP_SERVER | |
558 | , "0.100" } | |
559 | ||
560 | , { "SMEMBERS" | |
561 | , "key" | |
562 | , "Get all the members in a set" | |
563 | , COMMAND_GROUP_SET | |
564 | , "0.07" } | |
565 | ||
566 | , { "SMOVE" | |
567 | , "source destination member" | |
568 | , "Move a member from one set to another" | |
569 | , COMMAND_GROUP_SET | |
570 | , "0.091" } | |
571 | ||
572 | , { "SORT" | |
573 | , "key (BY pattern)? (LIMIT start count)? (GET pattern)* (ASC|DESC)? (ALPHA)? (STORE destination)?" | |
574 | , "Sort the elements in a list, set or sorted set" | |
575 | , COMMAND_GROUP_GENERIC | |
576 | , "0.07" } | |
577 | ||
578 | , { "SPOP" | |
579 | , "key" | |
580 | , "Remove and return a random member from a set" | |
581 | , COMMAND_GROUP_SET | |
582 | , "0.101" } | |
583 | ||
584 | , { "SRANDMEMBER" | |
585 | , "key" | |
586 | , "Get a random member from a set" | |
587 | , COMMAND_GROUP_SET | |
588 | , "1.001" } | |
589 | ||
590 | , { "SREM" | |
591 | , "key member" | |
592 | , "Remove a member from a set" | |
593 | , COMMAND_GROUP_SET | |
594 | , "0.07" } | |
595 | ||
596 | , { "STRLEN" | |
597 | , "key" | |
598 | , "Get the length of the value stored in a key" | |
599 | , COMMAND_GROUP_STRING | |
600 | , "2.1.2" } | |
601 | ||
602 | , { "SUBSCRIBE" | |
603 | , "channel" | |
604 | , "Listen for messages published to the given channels" | |
605 | , COMMAND_GROUP_PUBSUB | |
606 | , "1.3.8" } | |
607 | ||
608 | , { "SUBSTR" | |
609 | , "key start stop" | |
610 | , "Get a substring of the string stored at a key" | |
611 | , COMMAND_GROUP_STRING | |
612 | , "1.3.4" } | |
613 | ||
614 | , { "SUNION" | |
615 | , "(key)+" | |
616 | , "Add multiple sets" | |
617 | , COMMAND_GROUP_SET | |
618 | , "0.091" } | |
619 | ||
620 | , { "SUNIONSTORE" | |
621 | , "destination (key)+" | |
622 | , "Add multiple sets and store the resulting set in a key" | |
623 | , COMMAND_GROUP_SET | |
624 | , "0.091" } | |
625 | ||
626 | , { "SYNC" | |
627 | , "-" | |
628 | , "Internal command used for replication" | |
629 | , COMMAND_GROUP_SERVER | |
630 | , "0.07" } | |
631 | ||
632 | , { "TTL" | |
633 | , "key" | |
634 | , "Get the time to live for a key" | |
635 | , COMMAND_GROUP_GENERIC | |
636 | , "0.100" } | |
637 | ||
638 | , { "TYPE" | |
639 | , "key" | |
640 | , "Determine the type stored at key" | |
641 | , COMMAND_GROUP_GENERIC | |
642 | , "0.07" } | |
643 | ||
644 | , { "UNSUBSCRIBE" | |
645 | , "(channel)*" | |
646 | , "Stop listening for messages posted to the given channels" | |
647 | , COMMAND_GROUP_PUBSUB | |
648 | , "1.3.8" } | |
649 | ||
650 | , { "UNWATCH" | |
651 | , "-" | |
652 | , "Forget about all watched keys" | |
653 | , COMMAND_GROUP_TRANSACTIONS | |
654 | , "2.1.0" } | |
655 | ||
656 | , { "WATCH" | |
657 | , "(key)+" | |
658 | , "Watch the given keys to determine execution of the MULTI/EXEC block" | |
659 | , COMMAND_GROUP_TRANSACTIONS | |
660 | , "2.1.0" } | |
661 | ||
662 | , { "ZADD" | |
663 | , "key score member" | |
664 | , "Add a member to a sorted set, or update its score if it already exists" | |
665 | , COMMAND_GROUP_SORTED_SET | |
666 | , "1.1" } | |
667 | ||
668 | , { "ZCARD" | |
669 | , "key" | |
670 | , "Get the number of members in a sorted set" | |
671 | , COMMAND_GROUP_SORTED_SET | |
672 | , "1.1" } | |
673 | ||
674 | , { "ZCOUNT" | |
675 | , "key min max" | |
676 | , "Count the members in a sorted set with scores within the given values" | |
677 | , COMMAND_GROUP_SORTED_SET | |
678 | , "1.3.3" } | |
679 | ||
680 | , { "ZINCRBY" | |
681 | , "key increment member" | |
682 | , "Increment the score of a member in a sorted set" | |
683 | , COMMAND_GROUP_SORTED_SET | |
684 | , "1.1" } | |
685 | ||
686 | , { "ZINTERSTORE" | |
687 | , "destination (key)+ (WEIGHTS weight)? (AGGREGATE SUM|MIN|MAX)?" | |
688 | , "Intersect multiple sorted sets and store the resulting sorted set in a new key" | |
689 | , COMMAND_GROUP_SORTED_SET | |
690 | , "1.3.10" } | |
691 | ||
692 | , { "ZRANGE" | |
693 | , "key start stop" | |
694 | , "Return a range of members in a sorted set, by index" | |
695 | , COMMAND_GROUP_SORTED_SET | |
696 | , "1.1" } | |
697 | ||
698 | , { "ZRANGEBYSCORE" | |
699 | , "key min max" | |
700 | , "Return a range of members in a sorted set, by score" | |
701 | , COMMAND_GROUP_SORTED_SET | |
702 | , "1.050" } | |
703 | ||
704 | , { "ZRANK" | |
705 | , "key member" | |
706 | , "Determine the index of a member in a sorted set" | |
707 | , COMMAND_GROUP_SORTED_SET | |
708 | , "1.3.4" } | |
709 | ||
710 | , { "ZREM" | |
711 | , "key member" | |
712 | , "Remove a member from a sorted set" | |
713 | , COMMAND_GROUP_SORTED_SET | |
714 | , "1.1" } | |
715 | ||
716 | , { "ZREMRANGEBYRANK" | |
717 | , "key start stop" | |
718 | , "Remove all members in a sorted set within the given indexes" | |
719 | , COMMAND_GROUP_SORTED_SET | |
720 | , "1.3.4" } | |
721 | ||
722 | , { "ZREMRANGEBYSCORE" | |
723 | , "key min max" | |
724 | , "Remove all members in a sorted set within the given scores" | |
725 | , COMMAND_GROUP_SORTED_SET | |
726 | , "1.1" } | |
727 | ||
728 | , { "ZREVRANGE" | |
729 | , "key start stop" | |
730 | , "Return a range of members in a sorted set, by index, with scores ordered from high to low" | |
731 | , COMMAND_GROUP_SORTED_SET | |
732 | , "1.1" } | |
733 | ||
734 | , { "ZREVRANK" | |
735 | , "key member" | |
736 | , "Determine the index of a member in a sorted set, with scores ordered from high to low" | |
737 | , COMMAND_GROUP_SORTED_SET | |
738 | , "1.3.4" } | |
739 | ||
740 | , { "ZSCORE" | |
741 | , "key member" | |
742 | , "Get the score associated with the given member in a sorted set" | |
743 | , COMMAND_GROUP_SORTED_SET | |
744 | , "1.1" } | |
745 | ||
746 | , { "ZUNIONSTORE" | |
747 | , "destination (key)+ (WEIGHTS weight)? (AGGREGATE SUM|MIN|MAX)?" | |
748 | , "Add multiple sorted sets and store the resulting sorted set in a new key" | |
749 | , COMMAND_GROUP_SORTED_SET | |
750 | , "1.3.10" } | |
751 | }; | |
752 | ||
753 | /* | |
754 | * Output command help to stdout. | |
755 | */ | |
756 | ||
757 | static void | |
758 | output_command_help(struct command_help *help) { | |
759 | printf("\n \x1b[1m%s\x1b[0m \x1b[90m%s\x1b[0m\n", help->name, help->params); | |
760 | printf(" \x1b[33msummary:\x1b[0m %s\n", help->summary); | |
761 | printf(" \x1b[33msince:\x1b[0m %s\n", help->since); | |
762 | printf(" \x1b[33mgroup:\x1b[0m %s\n", command_group_type_names[help->group]); | |
763 | } | |
764 | ||
765 | /* | |
766 | * Return command group type by name string. | |
767 | */ | |
768 | ||
769 | static command_group_type_t | |
770 | command_group_type_by_name(const char *name) { | |
771 | for (int i = 0; i < COMMAND_GROUP_LENGTH; ++i) { | |
772 | const char *group = command_group_type_names[i]; | |
773 | if (0 == strcasecmp(name, group)) return i; | |
774 | } | |
775 | return 0; | |
776 | } | |
777 | ||
778 | /* | |
779 | * Output group names. | |
780 | */ | |
781 | ||
782 | static void | |
783 | output_group_help() { | |
784 | for (int i = 0; i < COMMAND_GROUP_LENGTH; ++i) { | |
785 | if (COMMAND_GROUP_UNKNOWN == i) continue; | |
786 | const char *group = command_group_type_names[i]; | |
787 | printf(" \x1b[90m-\x1b[0m %s\n", group); | |
788 | } | |
789 | } | |
790 | ||
791 | /* | |
792 | * Output all command help, filtering by group or command name. | |
793 | */ | |
794 | ||
795 | static void | |
796 | output_help(int argc, const char **argv) { | |
797 | int len = sizeof(command_help) / sizeof(struct command_help); | |
798 | ||
799 | if (argc && 0 == strcasecmp("groups", argv[0])) { | |
800 | output_group_help(); | |
801 | return; | |
802 | } | |
803 | ||
804 | command_group_type_t group = argc | |
805 | ? command_group_type_by_name(argv[0]) | |
806 | : COMMAND_GROUP_UNKNOWN; | |
807 | ||
808 | for (int i = 0; i < len; ++i) { | |
809 | struct command_help help = command_help[i]; | |
810 | if (argc && !group && 0 != strcasecmp(help.name, argv[0])) continue; | |
811 | if (group && group != help.group) continue; | |
812 | output_command_help(&help); | |
813 | } | |
814 | puts(""); | |
815 | } |