mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
redis-cli add control on raw format line delimiter (#7841)
Adding -D option for redis-cli to control newline between command responses in raw mode. Also removing cleanup code before calling exit, just in order to avoid adding more adding more cleanup code (redis doesn't bother to release allocations before exit anyway) Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
parent
66ee45b65c
commit
6418d767e8
@ -239,6 +239,7 @@ static struct config {
|
|||||||
int output; /* output mode, see OUTPUT_* defines */
|
int output; /* output mode, see OUTPUT_* defines */
|
||||||
int push_output; /* Should we display spontaneous PUSH replies */
|
int push_output; /* Should we display spontaneous PUSH replies */
|
||||||
sds mb_delim;
|
sds mb_delim;
|
||||||
|
sds cmd_delim;
|
||||||
char prompt[128];
|
char prompt[128];
|
||||||
char *eval;
|
char *eval;
|
||||||
int eval_ldb;
|
int eval_ldb;
|
||||||
@ -1236,7 +1237,7 @@ static sds cliFormatReply(redisReply *reply, int mode, int verbatim) {
|
|||||||
out = cliFormatReplyTTY(reply, "");
|
out = cliFormatReplyTTY(reply, "");
|
||||||
} else if (mode == OUTPUT_RAW) {
|
} else if (mode == OUTPUT_RAW) {
|
||||||
out = cliFormatReplyRaw(reply);
|
out = cliFormatReplyRaw(reply);
|
||||||
out = sdscatlen(out, "\n", 1);
|
out = sdscatsds(out, config.cmd_delim);
|
||||||
} else if (mode == OUTPUT_CSV) {
|
} else if (mode == OUTPUT_CSV) {
|
||||||
out = cliFormatReplyCSV(reply);
|
out = cliFormatReplyCSV(reply);
|
||||||
out = sdscatlen(out, "\n", 1);
|
out = sdscatlen(out, "\n", 1);
|
||||||
@ -1604,6 +1605,9 @@ static int parseOptions(int argc, char **argv) {
|
|||||||
} else if (!strcmp(argv[i],"-d") && !lastarg) {
|
} else if (!strcmp(argv[i],"-d") && !lastarg) {
|
||||||
sdsfree(config.mb_delim);
|
sdsfree(config.mb_delim);
|
||||||
config.mb_delim = sdsnew(argv[++i]);
|
config.mb_delim = sdsnew(argv[++i]);
|
||||||
|
} else if (!strcmp(argv[i],"-D") && !lastarg) {
|
||||||
|
sdsfree(config.cmd_delim);
|
||||||
|
config.cmd_delim = sdsnew(argv[++i]);
|
||||||
} else if (!strcmp(argv[i],"--verbose")) {
|
} else if (!strcmp(argv[i],"--verbose")) {
|
||||||
config.verbose = 1;
|
config.verbose = 1;
|
||||||
} else if (!strcmp(argv[i],"--cluster") && !lastarg) {
|
} else if (!strcmp(argv[i],"--cluster") && !lastarg) {
|
||||||
@ -1807,7 +1811,8 @@ static void usage(void) {
|
|||||||
" -n <db> Database number.\n"
|
" -n <db> Database number.\n"
|
||||||
" -3 Start session in RESP3 protocol mode.\n"
|
" -3 Start session in RESP3 protocol mode.\n"
|
||||||
" -x Read last argument from STDIN.\n"
|
" -x Read last argument from STDIN.\n"
|
||||||
" -d <delimiter> Multi-bulk delimiter in for raw formatting (default: \\n).\n"
|
" -d <delimiter> Delimiter between response bulks for raw formatting (default: \\n).\n"
|
||||||
|
" -D <delimiter> Delimiter between responses for raw formatting (default: \\n).\n"
|
||||||
" -c Enable cluster mode (follow -ASK and -MOVED redirections).\n"
|
" -c Enable cluster mode (follow -ASK and -MOVED redirections).\n"
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
" --tls Establish a secure TLS connection.\n"
|
" --tls Establish a secure TLS connection.\n"
|
||||||
@ -5443,8 +5448,6 @@ static void clusterManagerMode(clusterManagerCommandProc *proc) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
cluster_manager_err:
|
cluster_manager_err:
|
||||||
freeClusterManager();
|
freeClusterManager();
|
||||||
sdsfree(config.hostip);
|
|
||||||
sdsfree(config.mb_delim);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8204,6 +8207,7 @@ int main(int argc, char **argv) {
|
|||||||
config.push_output = 1;
|
config.push_output = 1;
|
||||||
}
|
}
|
||||||
config.mb_delim = sdsnew("\n");
|
config.mb_delim = sdsnew("\n");
|
||||||
|
config.cmd_delim = sdsnew("\n");
|
||||||
|
|
||||||
firstarg = parseOptions(argc,argv);
|
firstarg = parseOptions(argc,argv);
|
||||||
argc -= firstarg;
|
argc -= firstarg;
|
||||||
@ -8227,8 +8231,6 @@ int main(int argc, char **argv) {
|
|||||||
if (CLUSTER_MANAGER_MODE()) {
|
if (CLUSTER_MANAGER_MODE()) {
|
||||||
clusterManagerCommandProc *proc = validateClusterManagerCommand();
|
clusterManagerCommandProc *proc = validateClusterManagerCommand();
|
||||||
if (!proc) {
|
if (!proc) {
|
||||||
sdsfree(config.hostip);
|
|
||||||
sdsfree(config.mb_delim);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
clusterManagerMode(proc);
|
clusterManagerMode(proc);
|
||||||
|
Loading…
Reference in New Issue
Block a user