From 273b96f9fa61adedbea22351293c78594c1af0fb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 27 May 2024 11:28:48 +0200 Subject: [PATCH] varlinkctl: tell user we are expecting method call parameters on STDIN When calling a method and the user hasn't provided any method call parameters on the command line we expect them on stdin instead. This might be confusing for people using varlinkctl for the first time, since omitting the parameters will just throw you at a blinking cursor. Let's be a bit more helpful, and show a friendly message when we are connected to a TTY (i.e. run interactively). --- src/varlinkctl/varlinkctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 676fb93054..a994c640ca 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -475,6 +475,9 @@ static int verb_call(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to parse parameters at :%u:%u: %m", line, column); } else { + if (isatty(STDIN_FILENO) > 0 && !arg_quiet) + log_notice("Expecting method call parameter JSON object on standard input."); + r = sd_json_parse_file_at(stdin, AT_FDCWD, "", 0, &jp, &line, &column); if (r < 0) return log_error_errno(r, "Failed to parse parameters at :%u:%u: %m", line, column); -- 2.25.1