varlinkctl: tell user we are expecting method call parameters on STDIN
authorLennart Poettering <lennart@poettering.net>
Mon, 27 May 2024 09:28:48 +0000 (11:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 13 Jun 2024 09:31:43 +0000 (11:31 +0200)
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

index 676fb930548537f836b5e93073a94b4800363d01..a994c640ca094a41833932827df1b63662394c78 100644 (file)
@@ -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 <argv[4]>:%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, "<stdin>", 0, &jp, &line, &column);
                 if (r < 0)
                         return log_error_errno(r, "Failed to parse parameters at <stdin>:%u:%u: %m", line, column);