MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / cliOutputHelp

Function cliOutputHelp

src/redis-cli.c:448–490  ·  view source on GitHub ↗

Output all command help, filtering by group or command name. */

Source from the content-addressed store, hash-verified

446
447/* Output all command help, filtering by group or command name. */
448static void cliOutputHelp(int argc, char **argv) {
449 int i, j, len;
450 int group = -1;
451 helpEntry *entry;
452 struct commandHelp *help;
453
454 if (argc == 0) {
455 cliOutputGenericHelp();
456 return;
457 } else if (argc > 0 && argv[0][0] == '@') {
458 len = sizeof(commandGroups)/sizeof(char*);
459 for (i = 0; i < len; i++) {
460 if (strcasecmp(argv[0]+1,commandGroups[i]) == 0) {
461 group = i;
462 break;
463 }
464 }
465 }
466
467 assert(argc > 0);
468 for (i = 0; i < helpEntriesLen; i++) {
469 entry = &helpEntries[i];
470 if (entry->type != CLI_HELP_COMMAND) continue;
471
472 help = entry->org;
473 if (group == -1) {
474 /* Compare all arguments */
475 if (argc <= entry->argc) {
476 for (j = 0; j < argc; j++) {
477 if (strcasecmp(argv[j],entry->argv[j]) != 0) break;
478 }
479 if (j == argc) {
480 cliOutputCommandHelp(help,1);
481 }
482 }
483 } else {
484 if (group == help->group) {
485 cliOutputCommandHelp(help,0);
486 }
487 }
488 }
489 printf("\r\n");
490}
491
492/* Linenoise completion callback. */
493static void completionCallback(const char *buf, linenoiseCompletions *lc) {

Callers 1

cliSendCommandFunction · 0.85

Calls 2

cliOutputGenericHelpFunction · 0.85
cliOutputCommandHelpFunction · 0.85

Tested by

no test coverage detected