diff --git a/CHANGELOG b/CHANGELOG index e23c6912..a1dbe3fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,9 @@ jc changelog - Note to Package Maintainers: please see note at 20210720 v1.16.0 - Add generic ASCII tables parser - Add support for streaming parsers +- Add -l option to allow line buffered output - Add ls command streaming parser tested on linux, macOS, and freeBSD +- Add ping command streaming parser tested on linux, macOS, and freeBSD 20210830 v1.16.2 - Note to Package Maintainers: please see note at 20210720 v1.16.0 diff --git a/README.md b/README.md index 1e2f976c..3e5d1a4c 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq)) - `--passwd` enables the `/etc/passwd` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd)) - `--ping` enables the `ping` and `ping6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping)) +- `--ping-s` enables the `ping` and `ping6` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s)) - `--pip-list` enables the `pip list` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list)) - `--pip-show` enables the `pip show` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show)) - `--ps` enables the `ps` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ps)) @@ -183,7 +184,8 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio ### Options - `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!) - `-d` debug mode. Prints trace messages if parsing issues are encountered (use `-dd` for verbose debugging) -- `-h` `jc` help. Use `jc -h --parser_name` for parser documentation +- `-h` help. Use `jc -h --parser_name` for parser documentation +- `-l` line buffer output - `-m` monochrome JSON output - `-p` pretty format the JSON output - `-q` quiet mode. Suppresses parser warning messages diff --git a/jc/cli.py b/jc/cli.py index c6c59ea0..93e5366d 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -331,6 +331,7 @@ def helptext(): -a about jc -d debug (-dd for verbose debug) -h help (-h --parser_name for parser documentation) + -l line buffer output -m monochrome output -p pretty print output -q quiet - suppress parser warnings @@ -521,6 +522,7 @@ def main(): about = 'a' in options debug = 'd' in options verbose_debug = True if options.count('d') > 1 else False + linebuf = 'l' in options mono = 'm' in options help_me = 'h' in options pretty = 'p' in options @@ -626,7 +628,7 @@ def main(): env_colors=jc_colors, mono=mono, piped_out=piped_output()), - flush=True) # unbuffers between piped commands + flush=linebuf) sys.exit(combined_exit_code(magic_exit_code, 0)) @@ -638,7 +640,8 @@ def main(): pretty=pretty, env_colors=jc_colors, mono=mono, - piped_out=piped_output())) + piped_out=piped_output()), + flush=linebuf) sys.exit(combined_exit_code(magic_exit_code, 0)) diff --git a/man/jc.1 b/man/jc.1 index 7a7b407e..74e656e7 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2021-09-10 1.17.0 "JSON CLI output utility" +.TH jc 1 2021-09-13 1.17.0 "JSON CLI output utility" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -247,6 +247,11 @@ Key/Value file parser \fB--ping\fP `ping` and `ping6` command parser +.TP +.B +\fB--ping-s\fP +`ping` and `ping6` command streaming parser + .TP .B \fB--pip-list\fP @@ -413,6 +418,10 @@ debug - show traceback (\fB-dd\fP for verbose traceback) help (\fB-h --parser_name\fP for parser documentation) .TP .B +\fB-l\fP +line buffer output +.TP +.B \fB-m\fP monochrome output .TP diff --git a/templates/manpage_template b/templates/manpage_template index 2f30969b..b5ea8c37 100644 --- a/templates/manpage_template +++ b/templates/manpage_template @@ -43,6 +43,10 @@ debug - show traceback (\fB-dd\fP for verbose traceback) help (\fB-h --parser_name\fP for parser documentation) .TP .B +\fB-l\fP +line buffer output +.TP +.B \fB-m\fP monochrome output .TP diff --git a/templates/readme_template b/templates/readme_template index 8466913a..a948d222 100644 --- a/templates/readme_template +++ b/templates/readme_template @@ -109,7 +109,8 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio ### Options - `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!) - `-d` debug mode. Prints trace messages if parsing issues are encountered (use `-dd` for verbose debugging) -- `-h` `jc` help. Use `jc -h --parser_name` for parser documentation +- `-h` help. Use `jc -h --parser_name` for parser documentation +- `-l` line buffer output - `-m` monochrome JSON output - `-p` pretty format the JSON output - `-q` quiet mode. Suppresses parser warning messages