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