2 // Auto-generated, do not edit. 
  12   G(UNKNOWN, "unknown") \ 
  16   G(GENERIC, "generic") \ 
  20   G(CONNECTION, "connection") \ 
  21   G(TRANSACTIONS, "transactions") \ 
  22   G(SORTED_SET, "sorted_set") 
  25  * Command group types. 
  29   #define G(GROUP, _) COMMAND_GROUP_##GROUP, 
  33 } command_group_type_t
; 
  36  * Command group type names. 
  39 static char *command_group_type_names
[] = { 
  40   #define G(_, STR) STR, 
  46  * Command help struct. 
  53   command_group_type_t group
; 
  58   , "Append a value to a key" 
  59   , COMMAND_GROUP_STRING
 
  64   , "Authenticate to the server" 
  65   , COMMAND_GROUP_CONNECTION
 
  70   , "Asynchronously rewrite the append-only file" 
  71   , COMMAND_GROUP_SERVER
 
  76   , "Asynchronously save the dataset to disk" 
  77   , COMMAND_GROUP_SERVER
 
  82   , "Remove and get the first element in a list, or block until one is available" 
  88   , "Remove and get the last element in a list, or block until one is available" 
  94   , "Get the value of a configuration parameter" 
  95   , COMMAND_GROUP_SERVER
 
 100   , "Set a configuration parameter to the given value" 
 101   , COMMAND_GROUP_SERVER
 
 106   , "Return the number of keys in the selected database" 
 107   , COMMAND_GROUP_SERVER
 
 112   , "Get debugging information about a key" 
 113   , COMMAND_GROUP_SERVER
 
 118   , "Make the server crash" 
 119   , COMMAND_GROUP_SERVER
 
 124   , "Decrement the integer value of a key by one" 
 125   , COMMAND_GROUP_STRING
 
 130   , "Decrement the integer value of a key by the given number" 
 131   , COMMAND_GROUP_STRING
 
 137   , COMMAND_GROUP_GENERIC
 
 142   , "Discard all commands issued after MULTI" 
 143   , COMMAND_GROUP_TRANSACTIONS
 
 148   , "Echo the given string" 
 149   , COMMAND_GROUP_CONNECTION
 
 154   , "Execute all commands issued after MULTI" 
 155   , COMMAND_GROUP_TRANSACTIONS
 
 160   , "Determine if a key exists" 
 161   , COMMAND_GROUP_SERVER
 
 166   , "Set a key's time to live in seconds" 
 167   , COMMAND_GROUP_GENERIC
 
 172   , "Set the expiration for a key as a UNIX timestamp" 
 173   , COMMAND_GROUP_GENERIC
 
 178   , "Remove all keys from all databases" 
 179   , COMMAND_GROUP_SERVER
 
 184   , "Remove all keys from the current database" 
 185   , COMMAND_GROUP_SERVER
 
 190   , "Get the value of a key" 
 191   , COMMAND_GROUP_STRING
 
 196   , "Set the string value of a key and return its old value" 
 197   , COMMAND_GROUP_STRING
 
 202   , "Delete a hash field" 
 208   , "Determine if a hash field exists" 
 214   , "Get the value of a hash field" 
 220   , "Get all the fields and values in a hash" 
 225   , "key field increment" 
 226   , "Increment the integer value of a hash field by the given number" 
 232   , "Get all the fields in a hash" 
 238   , "Get the number of fields in a hash" 
 244   , "Get the values of all the given hash fields" 
 249   , "key (field value)+" 
 250   , "Set multiple hash fields to multiple values" 
 256   , "Set the string value of a hash field" 
 262   , "Set the value of a hash field, only if the field does not exist" 
 268   , "Get all the values in a hash" 
 274   , "Increment the integer value of a key by one" 
 275   , COMMAND_GROUP_STRING
 
 280   , "Increment the integer value of a key by the given number" 
 281   , COMMAND_GROUP_STRING
 
 286   , "Get information and statistics about the server" 
 287   , COMMAND_GROUP_SERVER
 
 292   , "Find all keys matching the given pattern" 
 293   , COMMAND_GROUP_GENERIC
 
 298   , "Get the UNIX time stamp of the last successful save to disk" 
 299   , COMMAND_GROUP_SERVER
 
 304   , "Get an element from a list by its index" 
 309   , "key BEFORE|AFTER pivot value" 
 310   , "Insert an element before or after another element in a list" 
 316   , "Get the length of a list" 
 322   , "Remove and get the first element in a list" 
 328   , "Prepend a value to a list" 
 334   , "Prepend a value to a list, only if the list exists" 
 340   , "Get a range of elements from a list" 
 346   , "Remove elements from a list" 
 352   , "Set the value of an element in a list by its index" 
 358   , "Trim a list to the specified range" 
 364   , "Get the values of all the given keys" 
 365   , COMMAND_GROUP_STRING
 
 370   , "Listen for all requests received by the server in real time" 
 371   , COMMAND_GROUP_SERVER
 
 376   , "Move a key to another database" 
 377   , COMMAND_GROUP_GENERIC
 
 382   , "Set multiple keys to multiple values" 
 383   , COMMAND_GROUP_STRING
 
 388   , "Set multiple keys to multiple values, only if none of the keys exist" 
 389   , COMMAND_GROUP_STRING
 
 394   , "Mark the start of a transaction block" 
 395   , COMMAND_GROUP_TRANSACTIONS
 
 400   , "Remove the expiration from a key" 
 401   , COMMAND_GROUP_GENERIC
 
 407   , COMMAND_GROUP_CONNECTION
 
 412   , "Listen for messages published to channels matching the given patterns" 
 413   , COMMAND_GROUP_PUBSUB
 
 418   , "Post a message to a channel" 
 419   , COMMAND_GROUP_PUBSUB
 
 424   , "Stop listening for messages posted to channels matching the given patterns" 
 425   , COMMAND_GROUP_PUBSUB
 
 430   , "Close the connection" 
 431   , COMMAND_GROUP_CONNECTION
 
 436   , "Return a random key from the keyspace" 
 437   , COMMAND_GROUP_GENERIC
 
 443   , COMMAND_GROUP_GENERIC
 
 448   , "Rename a key, only if the new key does not exist" 
 449   , COMMAND_GROUP_GENERIC
 
 454   , "Remove and get the last element in a list" 
 459   , "source destination" 
 460   , "Remove the last element in a list, append it to another list and return it" 
 466   , "Append a value to a list" 
 472   , "Append a value to a list, only if the list exists" 
 478   , "Add a member to a set" 
 484   , "Synchronously save the dataset to disk" 
 485   , COMMAND_GROUP_SERVER
 
 490   , "Get the number of members in a set" 
 496   , "Subtract multiple sets" 
 501   , "destination (key)+" 
 502   , "Subtract multiple sets and store the resulting set in a key" 
 508   , "Change the selected database for the current connection" 
 509   , COMMAND_GROUP_CONNECTION
 
 514   , "Set the string value of a key" 
 515   , COMMAND_GROUP_STRING
 
 519   , "key timestamp value" 
 520   , "Set the value and expiration of a key" 
 521   , COMMAND_GROUP_STRING
 
 526   , "Set the value of a key, only if the key does not exist" 
 527   , COMMAND_GROUP_STRING
 
 532   , "Synchronously save the dataset to disk and then shut down the server" 
 533   , COMMAND_GROUP_SERVER
 
 538   , "Intersect multiple sets" 
 543   , "destination (key)+" 
 544   , "Intersect multiple sets and store the resulting set in a key" 
 550   , "Determine if a given value is a member of a set" 
 556   , "Make the server a slave of another instance, or promote it as master" 
 557   , COMMAND_GROUP_SERVER
 
 562   , "Get all the members in a set" 
 567   , "source destination member" 
 568   , "Move a member from one set to another" 
 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
 
 580   , "Remove and return a random member from a set" 
 586   , "Get a random member from a set" 
 592   , "Remove a member from a set" 
 598   , "Get the length of the value stored in a key" 
 599   , COMMAND_GROUP_STRING
 
 604   , "Listen for messages published to the given channels" 
 605   , COMMAND_GROUP_PUBSUB
 
 610   , "Get a substring of the string stored at a key" 
 611   , COMMAND_GROUP_STRING
 
 616   , "Add multiple sets" 
 621   , "destination (key)+" 
 622   , "Add multiple sets and store the resulting set in a key" 
 628   , "Internal command used for replication" 
 629   , COMMAND_GROUP_SERVER
 
 634   , "Get the time to live for a key" 
 635   , COMMAND_GROUP_GENERIC
 
 640   , "Determine the type stored at key" 
 641   , COMMAND_GROUP_GENERIC
 
 646   , "Stop listening for messages posted to the given channels" 
 647   , COMMAND_GROUP_PUBSUB
 
 652   , "Forget about all watched keys" 
 653   , COMMAND_GROUP_TRANSACTIONS
 
 658   , "Watch the given keys to determine execution of the MULTI/EXEC block" 
 659   , COMMAND_GROUP_TRANSACTIONS
 
 664   , "Add a member to a sorted set, or update its score if it already exists" 
 665   , COMMAND_GROUP_SORTED_SET
 
 670   , "Get the number of members in a sorted set" 
 671   , COMMAND_GROUP_SORTED_SET
 
 676   , "Count the members in a sorted set with scores within the given values" 
 677   , COMMAND_GROUP_SORTED_SET
 
 681   , "key increment member" 
 682   , "Increment the score of a member in a sorted set" 
 683   , COMMAND_GROUP_SORTED_SET
 
 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
 
 694   , "Return a range of members in a sorted set, by index" 
 695   , COMMAND_GROUP_SORTED_SET
 
 700   , "Return a range of members in a sorted set, by score" 
 701   , COMMAND_GROUP_SORTED_SET
 
 706   , "Determine the index of a member in a sorted set" 
 707   , COMMAND_GROUP_SORTED_SET
 
 712   , "Remove a member from a sorted set" 
 713   , COMMAND_GROUP_SORTED_SET
 
 716   , { "ZREMRANGEBYRANK" 
 718   , "Remove all members in a sorted set within the given indexes" 
 719   , COMMAND_GROUP_SORTED_SET
 
 722   , { "ZREMRANGEBYSCORE" 
 724   , "Remove all members in a sorted set within the given scores" 
 725   , COMMAND_GROUP_SORTED_SET
 
 730   , "Return a range of members in a sorted set, by index, with scores ordered from high to low" 
 731   , COMMAND_GROUP_SORTED_SET
 
 736   , "Determine the index of a member in a sorted set, with scores ordered from high to low" 
 737   , COMMAND_GROUP_SORTED_SET
 
 742   , "Get the score associated with the given member in a sorted set" 
 743   , COMMAND_GROUP_SORTED_SET
 
 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
 
 754  * Output command help to stdout. 
 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
]); 
 766  * Return command group type by name string. 
 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
; 
 779  * Output group names. 
 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
); 
 792  * Output all command help, filtering by group or command name. 
 796 output_help(int argc
, const char **argv
) { 
 797   int len 
= sizeof(command_help
) / sizeof(struct command_help
); 
 799         if (argc 
&& 0 == strcasecmp("groups", argv
[0])) { 
 804         command_group_type_t group 
= argc
 
 805     ? command_group_type_by_name(argv
[0]) 
 806     : COMMAND_GROUP_UNKNOWN
; 
 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
);