aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-09-01 19:56:11 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-09-01 20:37:08 +0200
commit16ec8261dc7af7dbed34376de44958b16fc4222c (patch)
tree4b36df2fb7f5ad7d204cf0c092662327c3bf24e5
parente49ff84b7448e8c9702648bcaf49b0344d077162 (diff)
downloadjson-rpc-shell-16ec8261dc7af7dbed34376de44958b16fc4222c.tar.gz
json-rpc-shell-16ec8261dc7af7dbed34376de44958b16fc4222c.tar.xz
json-rpc-shell-16ec8261dc7af7dbed34376de44958b16fc4222c.zip
Make the verbose mode also show the raw input
To make it more useful for debugging. We might also tie this to the --debug option, though that would be a bit chaotic.
-rw-r--r--json-rpc-shell.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index a95e99e..bbbe46a 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -2892,6 +2892,20 @@ make_json_rpc_call (struct app_context *ctx,
goto fail;
}
+ if (ctx->verbose)
+ {
+ char *buf_term =
+ iconv_xstrdup (ctx->term_from_utf8, buf.str, buf.len, NULL);
+ if (!buf_term)
+ print_error ("%s: %s", "verbose", "character conversion failed");
+ else
+ {
+ print_attributed (ctx, stdout, ATTR_INCOMING, "%s", buf_term);
+ fputs ("\n", stdout);
+ }
+ free (buf_term);
+ }
+
bool success = false;
if (id)
success = parse_response (ctx, &buf, pipeline);
@@ -2911,7 +2925,7 @@ make_json_rpc_call (struct app_context *ctx,
if (!s)
print_error ("character conversion failed for `%s'",
"raw response data");
- else
+ else if (!ctx->verbose /* already printed */)
printf ("%s: %s\n", "raw response data", s);
free (s);
}