]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
report: add -j shortcut
authorLennart Poettering <lennart@amutable.com>
Wed, 18 Feb 2026 13:07:45 +0000 (14:07 +0100)
committerLennart Poettering <lennart@amutable.com>
Fri, 20 Feb 2026 07:25:12 +0000 (08:25 +0100)
json output is going to be used very frequently, hence provide a
shortcut for it, like many our tools do it.

man/systemd-report.xml
src/report/report.c

index 530dac1e1421f443506fb6f031bb6eb96f73d0df..010cf2e2f16c67127f0b3938c33d4c2c439f3a0d 100644 (file)
@@ -90,6 +90,7 @@
 
       <xi:include href="standard-options.xml" xpointer="no-pager" />
       <xi:include href="standard-options.xml" xpointer="json" />
+      <xi:include href="standard-options.xml" xpointer="j" />
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
     </variablelist>
index d6c52b6ff9e23465b0d58512fa012d7a3090d079..bf216dd2e3922205bd5eef19a09fc389d7898236 100644 (file)
@@ -607,6 +607,8 @@ static int verb_help(int argc, char *argv[], void *userdata) {
                "     --system           Connect to system service manager (default)\n"
                "     --json=pretty|short\n"
                "                        Configure JSON output\n"
+               "  -j                    Equivalent to --json=pretty (on TTY) or --json=short\n"
+               "                        (otherwise)\n"
                "\nSee the %2$s for details.\n",
                program_invocation_short_name,
                link,
@@ -642,7 +644,7 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+        while ((c = getopt_long(argc, argv, "hj", options, NULL)) >= 0)
                 switch (c) {
                 case 'h':
                         return verb_help(/* argc= */ 0, /* argv= */ NULL, /* userdata= */ NULL);
@@ -669,6 +671,10 @@ static int parse_argv(int argc, char *argv[]) {
 
                         break;
 
+                case 'j':
+                        arg_json_format_flags = SD_JSON_FORMAT_PRETTY_AUTO|SD_JSON_FORMAT_COLOR_AUTO;
+                        break;
+
                 case '?':
                         return -EINVAL;