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

Function cliFormatReplyRaw

src/redis-cli.c:943–1014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

941}
942
943static sds cliFormatReplyRaw(redisReply *r) {
944 sds out = sdsempty(), tmp;
945 size_t i;
946
947 switch (r->type) {
948 case REDIS_REPLY_NIL:
949 /* Nothing... */
950 break;
951 case REDIS_REPLY_ERROR:
952 out = sdscatlen(out,r->str,r->len);
953 out = sdscatlen(out,"\n",1);
954 break;
955 case REDIS_REPLY_STATUS:
956 case REDIS_REPLY_STRING:
957 case REDIS_REPLY_VERB:
958 if (r->type == REDIS_REPLY_STATUS && config.eval_ldb) {
959 /* The Lua debugger replies with arrays of simple (status)
960 * strings. We colorize the output for more fun if this
961 * is a debugging session. */
962
963 /* Detect the end of a debugging session. */
964 if (strstr(r->str,"<endsession>") == r->str) {
965 config.enable_ldb_on_eval = 0;
966 config.eval_ldb = 0;
967 config.eval_ldb_end = 1; /* Signal the caller session ended. */
968 config.output = OUTPUT_STANDARD;
969 cliRefreshPrompt();
970 } else {
971 out = sdsCatColorizedLdbReply(out,r->str,r->len);
972 }
973 } else {
974 out = sdscatlen(out,r->str,r->len);
975 }
976 break;
977 case REDIS_REPLY_BOOL:
978 out = sdscat(out,r->integer ? "(true)" : "(false)");
979 break;
980 case REDIS_REPLY_INTEGER:
981 out = sdscatprintf(out,"%lld",r->integer);
982 break;
983 case REDIS_REPLY_DOUBLE:
984 out = sdscatprintf(out,"%s",r->str);
985 break;
986 case REDIS_REPLY_SET:
987 case REDIS_REPLY_ARRAY:
988 case REDIS_REPLY_PUSH:
989 for (i = 0; i < r->elements; i++) {
990 if (i > 0) out = sdscat(out,config.mb_delim);
991 tmp = cliFormatReplyRaw(r->element[i]);
992 out = sdscatlen(out,tmp,sdslen(tmp));
993 sdsfree(tmp);
994 }
995 break;
996 case REDIS_REPLY_MAP:
997 for (i = 0; i < r->elements; i += 2) {
998 if (i > 0) out = sdscat(out,config.mb_delim);
999 tmp = cliFormatReplyRaw(r->element[i]);
1000 out = sdscatlen(out,tmp,sdslen(tmp));

Callers 2

cliFormatReplyFunction · 0.85

Calls 8

sdsemptyFunction · 0.85
sdscatlenFunction · 0.85
cliRefreshPromptFunction · 0.85
sdsCatColorizedLdbReplyFunction · 0.85
sdscatFunction · 0.85
sdscatprintfFunction · 0.85
sdslenFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected