MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cliInitHelp

Function cliInitHelp

app/redis-6.2.6/src/redis-cli.c:522–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520}
521
522static void cliInitHelp(void) {
523 int commandslen = sizeof(commandHelp)/sizeof(struct commandHelp);
524 int groupslen = sizeof(commandGroups)/sizeof(char*);
525 int i, len, pos = 0;
526 helpEntry tmp;
527
528 helpEntriesLen = len = commandslen+groupslen;
529 helpEntries = zmalloc(sizeof(helpEntry)*len);
530
531 for (i = 0; i < groupslen; i++) {
532 tmp.argc = 1;
533 tmp.argv = zmalloc(sizeof(sds));
534 tmp.argv[0] = sdscatprintf(sdsempty(),"@%s",commandGroups[i]);
535 tmp.full = tmp.argv[0];
536 tmp.type = CLI_HELP_GROUP;
537 tmp.org = NULL;
538 helpEntries[pos++] = tmp;
539 }
540
541 for (i = 0; i < commandslen; i++) {
542 tmp.argv = sdssplitargs(commandHelp[i].name,&tmp.argc);
543 tmp.full = sdsnew(commandHelp[i].name);
544 tmp.type = CLI_HELP_COMMAND;
545 tmp.org = &commandHelp[i];
546 helpEntries[pos++] = tmp;
547 }
548}
549
550/* cliInitHelp() setups the helpEntries array with the command and group
551 * names from the help.h file. However the Redis instance we are connecting

Callers 1

replFunction · 0.85

Calls 5

zmallocFunction · 0.85
sdscatprintfFunction · 0.85
sdsemptyFunction · 0.85
sdssplitargsFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected