]> git.gsnw.org Git - fping.git/commitdiff
Allow --json also for loop-mode
authorDavid Schweikert <david@schweikert.ch>
Sun, 7 Dec 2025 13:11:22 +0000 (14:11 +0100)
committerDavid Schweikert <david@schweikert.ch>
Sun, 7 Dec 2025 16:47:00 +0000 (17:47 +0100)
ci/test-16-json-output.pl
doc/fping.pod
src/fping.c

index 08e9c593d7afaf1b31cedb24637cef941d788022..c97c6004b592e3cee8c47f7eb36f903d3c37a047 100644 (file)
@@ -189,5 +189,5 @@ $cmd->stderr_is_eq("");
 my $cmd = Test::Command->new(cmd => "fping -J 127.0.0.1");
 $cmd->exit_is_num(1);
 $cmd->stdout_is_eq("");
-$cmd->stderr_is_eq("fping: option -J, --json requires -c or -C\n");
+$cmd->stderr_is_eq("fping: option -J, --json requires -c, -C, or -l\n");
 }
index fb611104964140d2bf0d7ace5d0f6f83b6b3912c..e868ac50390b83db4594f4318eb38d50b5c8857f 100644 (file)
@@ -167,7 +167,7 @@ IPv4 only, requires root privileges or cap_net_raw.
 
 =item B<-J>, B<--json>
 
-Format output JSON (-c or -C required)
+Format output JSON (-c, -C, or -l required)
 
 Example usage:
 
index e9d89bff77cb2348e8e64ee0fd926e457a97aa84..7f58b817f78d4cc872fe763f56d8475d1a8e7b38 100644 (file)
@@ -1072,8 +1072,8 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    if (json_flag && !count_flag) {
-        fprintf(stderr, "%s: option -J, --json requires -c or -C\n", prog);
+    if (json_flag && !count_flag && !loop_flag) {
+        fprintf(stderr, "%s: option -J, --json requires -c, -C, or -l\n", prog);
         exit(1);
     }
 
@@ -3944,7 +3944,7 @@ void usage(int is_error)
     fprintf(out, "   -D, --timestamp    print timestamp before each output line\n");
     fprintf(out, "       --timestamp-format=FORMAT  show timestamp in the given format (-D required): ctime|iso|rfc3339\n");
     fprintf(out, "   -e, --elapsed      show elapsed time on return packets\n");
-    fprintf(out, "   -J, --json         output in JSON format (-c or -C required)\n");
+    fprintf(out, "   -J, --json         output in JSON format (-c, -C, or -l required)\n");
     fprintf(out, "   -n, --name         show targets by name (reverse-DNS lookup for target IPs)\n");
     fprintf(out, "   -N, --netdata      output compatible for netdata (-l -Q are required)\n");
     fprintf(out, "   -o, --outage       show the accumulated outage time (lost packets * packet interval)\n");