| 786 | } |
| 787 | |
| 788 | static sds cliFormatReplyTTY(redisReply *r, char *prefix) { |
| 789 | sds out = sdsempty(); |
| 790 | switch (r->type) { |
| 791 | case REDIS_REPLY_ERROR: |
| 792 | out = sdscatprintf(out,"(error) %s\n", r->str); |
| 793 | break; |
| 794 | case REDIS_REPLY_STATUS: |
| 795 | out = sdscat(out,r->str); |
| 796 | out = sdscat(out,"\n"); |
| 797 | break; |
| 798 | case REDIS_REPLY_INTEGER: |
| 799 | out = sdscatprintf(out,"(integer) %lld\n",r->integer); |
| 800 | break; |
| 801 | case REDIS_REPLY_DOUBLE: |
| 802 | out = sdscatprintf(out,"(double) %s\n",r->str); |
| 803 | break; |
| 804 | case REDIS_REPLY_STRING: |
| 805 | case REDIS_REPLY_VERB: |
| 806 | /* If you are producing output for the standard output we want |
| 807 | * a more interesting output with quoted characters and so forth, |
| 808 | * unless it's a verbatim string type. */ |
| 809 | if (r->type == REDIS_REPLY_STRING) { |
| 810 | out = sdscatrepr(out,r->str,r->len); |
| 811 | out = sdscat(out,"\n"); |
| 812 | } else { |
| 813 | out = sdscatlen(out,r->str,r->len); |
| 814 | out = sdscat(out,"\n"); |
| 815 | } |
| 816 | break; |
| 817 | case REDIS_REPLY_NIL: |
| 818 | out = sdscat(out,"(nil)\n"); |
| 819 | break; |
| 820 | case REDIS_REPLY_BOOL: |
| 821 | out = sdscat(out,r->integer ? "(true)\n" : "(false)\n"); |
| 822 | break; |
| 823 | case REDIS_REPLY_ARRAY: |
| 824 | case REDIS_REPLY_MAP: |
| 825 | case REDIS_REPLY_SET: |
| 826 | case REDIS_REPLY_PUSH: |
| 827 | if (r->elements == 0) { |
| 828 | if (r->type == REDIS_REPLY_ARRAY) |
| 829 | out = sdscat(out,"(empty array)\n"); |
| 830 | else if (r->type == REDIS_REPLY_MAP) |
| 831 | out = sdscat(out,"(empty hash)\n"); |
| 832 | else if (r->type == REDIS_REPLY_SET) |
| 833 | out = sdscat(out,"(empty set)\n"); |
| 834 | else if (r->type == REDIS_REPLY_PUSH) |
| 835 | out = sdscat(out,"(empty push)\n"); |
| 836 | else |
| 837 | out = sdscat(out,"(empty aggregate type)\n"); |
| 838 | } else { |
| 839 | unsigned int i, idxlen = 0; |
| 840 | char _prefixlen[16]; |
| 841 | char _prefixfmt[16]; |
| 842 | sds _prefix; |
| 843 | sds tmp; |
| 844 | |
| 845 | /* Calculate chars needed to represent the largest index */ |
no test coverage detected