1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

add line buffer output option

This commit is contained in:
Kelly Brazil
2021-09-13 21:14:38 -07:00
parent bf0bc32d7a
commit af615c7f4b
6 changed files with 26 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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