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

Function cliFormatReplyTTY

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

Source from the content-addressed store, hash-verified

979}
980
981static sds cliFormatReplyTTY(redisReply *r, char *prefix) {
982 sds out = sdsempty();
983 switch (r->type) {
984 case REDIS_REPLY_ERROR:
985 out = sdscatprintf(out,"(error) %s\n", r->str);
986 break;
987 case REDIS_REPLY_STATUS:
988 out = sdscat(out,r->str);
989 out = sdscat(out,"\n");
990 break;
991 case REDIS_REPLY_INTEGER:
992 out = sdscatprintf(out,"(integer) %lld\n",r->integer);
993 break;
994 case REDIS_REPLY_DOUBLE:
995 out = sdscatprintf(out,"(double) %s\n",r->str);
996 break;
997 case REDIS_REPLY_STRING:
998 case REDIS_REPLY_VERB:
999 /* If you are producing output for the standard output we want
1000 * a more interesting output with quoted characters and so forth,
1001 * unless it's a verbatim string type. */
1002 if (r->type == REDIS_REPLY_STRING) {
1003 out = sdscatrepr(out,r->str,r->len);
1004 out = sdscat(out,"\n");
1005 } else {
1006 out = sdscatlen(out,r->str,r->len);
1007 out = sdscat(out,"\n");
1008 }
1009 break;
1010 case REDIS_REPLY_NIL:
1011 out = sdscat(out,"(nil)\n");
1012 break;
1013 case REDIS_REPLY_BOOL:
1014 out = sdscat(out,r->integer ? "(true)\n" : "(false)\n");
1015 break;
1016 case REDIS_REPLY_ARRAY:
1017 case REDIS_REPLY_MAP:
1018 case REDIS_REPLY_SET:
1019 case REDIS_REPLY_PUSH:
1020 if (r->elements == 0) {
1021 if (r->type == REDIS_REPLY_ARRAY)
1022 out = sdscat(out,"(empty array)\n");
1023 else if (r->type == REDIS_REPLY_MAP)
1024 out = sdscat(out,"(empty hash)\n");
1025 else if (r->type == REDIS_REPLY_SET)
1026 out = sdscat(out,"(empty set)\n");
1027 else if (r->type == REDIS_REPLY_PUSH)
1028 out = sdscat(out,"(empty push)\n");
1029 else
1030 out = sdscat(out,"(empty aggregate type)\n");
1031 } else {
1032 unsigned int i, idxlen = 0;
1033 char _prefixlen[16];
1034 char _prefixfmt[16];
1035 sds _prefix;
1036 sds tmp;
1037
1038 /* Calculate chars needed to represent the largest index */

Callers 1

cliFormatReplyFunction · 0.85

Calls 11

sdsemptyFunction · 0.85
sdscatprintfFunction · 0.85
sdscatFunction · 0.85
sdscatreprFunction · 0.85
sdscatlenFunction · 0.85
memsetFunction · 0.85
sdsnewFunction · 0.85
snprintfFunction · 0.85
sdslenFunction · 0.85
sdsfreeFunction · 0.85
sdsrangeFunction · 0.85

Tested by

no test coverage detected