Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b21dd082
Commit
b21dd082
authored
Sep 23, 2019
by
antirez
Browse files
redis-cli: CSV and RAW target for more RESP3 types.
parent
cc108057
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
b21dd082
...
@@ -1006,9 +1006,15 @@ static sds cliFormatReplyRaw(redisReply *r) {
...
@@ -1006,9 +1006,15 @@ static sds cliFormatReplyRaw(redisReply *r) {
out = sdscatlen(out,r->str,r->len);
out = sdscatlen(out,r->str,r->len);
}
}
break;
break;
case REDIS_REPLY_BOOL:
out = sdscat(out,r->integer ? "(true)" : "(false)");
break;
case REDIS_REPLY_INTEGER:
case REDIS_REPLY_INTEGER:
out = sdscatprintf(out,"%lld",r->integer);
out = sdscatprintf(out,"%lld",r->integer);
break;
break;
case REDIS_REPLY_DOUBLE:
out = sdscatprintf(out,"%s",r->str);
break;
case REDIS_REPLY_ARRAY:
case REDIS_REPLY_ARRAY:
for (i = 0; i < r->elements; i++) {
for (i = 0; i < r->elements; i++) {
if (i > 0) out = sdscat(out,config.mb_delim);
if (i > 0) out = sdscat(out,config.mb_delim);
...
@@ -1017,6 +1023,19 @@ static sds cliFormatReplyRaw(redisReply *r) {
...
@@ -1017,6 +1023,19 @@ static sds cliFormatReplyRaw(redisReply *r) {
sdsfree(tmp);
sdsfree(tmp);
}
}
break;
break;
case REDIS_REPLY_MAP:
for (i = 0; i < r->elements; i += 2) {
if (i > 0) out = sdscat(out,config.mb_delim);
tmp = cliFormatReplyRaw(r->element[i]);
out = sdscatlen(out,tmp,sdslen(tmp));
sdsfree(tmp);
out = sdscatlen(out," ",1);
tmp = cliFormatReplyRaw(r->element[i+1]);
out = sdscatlen(out,tmp,sdslen(tmp));
sdsfree(tmp);
}
break;
default:
default:
fprintf(stderr,"Unknown reply type: %d\n", r->type);
fprintf(stderr,"Unknown reply type: %d\n", r->type);
exit(1);
exit(1);
...
@@ -1039,14 +1058,21 @@ static sds cliFormatReplyCSV(redisReply *r) {
...
@@ -1039,14 +1058,21 @@ static sds cliFormatReplyCSV(redisReply *r) {
case REDIS_REPLY_INTEGER:
case REDIS_REPLY_INTEGER:
out = sdscatprintf(out,"%lld",r->integer);
out = sdscatprintf(out,"%lld",r->integer);
break;
break;
case REDIS_REPLY_DOUBLE:
out = sdscatprintf(out,"%s",r->str);
break;
case REDIS_REPLY_STRING:
case REDIS_REPLY_STRING:
case REDIS_REPLY_VERB:
case REDIS_REPLY_VERB:
out = sdscatrepr(out,r->str,r->len);
out = sdscatrepr(out,r->str,r->len);
break;
break;
case REDIS_REPLY_NIL:
case REDIS_REPLY_NIL:
out = sdscat(out,"NIL");
out = sdscat(out,"NULL");
break;
case REDIS_REPLY_BOOL:
out = sdscat(out,r->integer ? "true" : "false");
break;
break;
case REDIS_REPLY_ARRAY:
case REDIS_REPLY_ARRAY:
case REDIS_REPLY_MAP: /* CSV has no map type, just output flat list. */
for (i = 0; i < r->elements; i++) {
for (i = 0; i < r->elements; i++) {
sds tmp = cliFormatReplyCSV(r->element[i]);
sds tmp = cliFormatReplyCSV(r->element[i]);
out = sdscatlen(out,tmp,sdslen(tmp));
out = sdscatlen(out,tmp,sdslen(tmp));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment