From c4c159f0560ed7c81fd4e2d031dee4f905d0421b Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 7 Sep 2022 13:56:16 -0700 Subject: [PATCH] clean up examples --- README.md | 37 ++++++++++++++++++++----------------- jc/cli.py | 1 - man/jc.1 | 29 +++++++++++++++++++++++------ templates/manpage_template | 29 +++++++++++++++++++++++------ templates/readme_template | 37 ++++++++++++++++++++----------------- 5 files changed, 86 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 6092740b..cfb329f6 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,9 @@ on Github. `jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. ```bash -COMMAND | jc PARSER [OPTIONS] +COMMAND | jc [OPTIONS] PARSER +cat FILE | jc [OPTIONS] PARSER +echo STRING | jc [OPTIONS] PARSER ``` Alternatively, the "magic" syntax can be used by prepending `jc` to the command @@ -141,6 +143,7 @@ to be converted. Options can be passed to `jc` immediately before the command is given. (Note: command aliases and shell builtins are not supported) ```bash jc [OPTIONS] COMMAND +jc [OPTIONS] /proc/ ``` The JSON output can be compact (default) or pretty formatted with the `-p` @@ -538,12 +541,12 @@ that case you can suppress the warning message with the `-q` cli option or the macOS: ```bash -cat lsof.out | jc --lsof -q +cat lsof.out | jc -q --lsof ``` or Windows: ```bash -type lsof.out | jc --lsof -q +type lsof.out | jc -q --lsof ``` Tested on: @@ -587,7 +590,7 @@ documentation. ### arp ```bash -arp | jc --arp -p # or: jc -p arp +arp | jc -p --arp # or: jc -p arp ``` ```json [ @@ -626,7 +629,7 @@ cat homes.csv ... ``` ```bash -cat homes.csv | jc --csv -p +cat homes.csv | jc -p --csv ``` ```json [ @@ -667,7 +670,7 @@ cat homes.csv | jc --csv -p ``` ### /etc/hosts file ```bash -cat /etc/hosts | jc --hosts -p +cat /etc/hosts | jc -p --hosts ``` ```json [ @@ -694,7 +697,7 @@ cat /etc/hosts | jc --hosts -p ``` ### ifconfig ```bash -ifconfig | jc --ifconfig -p # or: jc -p ifconfig +ifconfig | jc -p --ifconfig # or: jc -p ifconfig ``` ```json [ @@ -752,7 +755,7 @@ Port = 50022 ForwardX11 = no ``` ```bash -cat example.ini | jc --ini -p +cat example.ini | jc -p --ini ``` ```json { @@ -774,7 +777,7 @@ cat example.ini | jc --ini -p ``` ### ls ```bash -$ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin +$ ls -l /usr/bin | jc -p --ls # or: jc -p ls -l /usr/bin ``` ```json [ @@ -810,7 +813,7 @@ $ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin ``` ### netstat ```bash -netstat -apee | jc --netstat -p # or: jc -p netstat -apee +netstat -apee | jc -p --netstat # or: jc -p netstat -apee ``` ```json [ @@ -898,7 +901,7 @@ netstat -apee | jc --netstat -p # or: jc -p netstat -apee ``` ### /etc/passwd file ```bash -cat /etc/passwd | jc --passwd -p +cat /etc/passwd | jc -p --passwd ``` ```json [ @@ -924,7 +927,7 @@ cat /etc/passwd | jc --passwd -p ``` ### ping ```bash -ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3 +ping 8.8.8.8 -c 3 | jc -p --ping # or: jc -p ping 8.8.8.8 -c 3 ``` ```json { @@ -977,7 +980,7 @@ ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3 ``` ### ps ```bash -ps axu | jc --ps -p # or: jc -p ps axu +ps axu | jc -p --ps # or: jc -p ps axu ``` ```json [ @@ -1024,7 +1027,7 @@ ps axu | jc --ps -p # or: jc -p ps axu ``` ### traceroute ```bash -traceroute -m 2 8.8.8.8 | jc --traceroute -p +traceroute -m 2 8.8.8.8 | jc -p --traceroute # or: jc -p traceroute -m 2 8.8.8.8 ``` ```json @@ -1089,7 +1092,7 @@ traceroute -m 2 8.8.8.8 | jc --traceroute -p ``` ### uptime ```bash -uptime | jc --uptime -p # or: jc -p uptime +uptime | jc -p --uptime # or: jc -p uptime ``` ```json { @@ -1134,7 +1137,7 @@ cat cd_catalog.xml ... ``` ```bash -cat cd_catalog.xml | jc --xml -p +cat cd_catalog.xml | jc -p --xml ``` ```json { @@ -1186,7 +1189,7 @@ spec: mode: ISTIO_MUTUAL ``` ```bash -cat istio.yaml | jc --yaml -p +cat istio.yaml | jc -p --yaml ``` ```json [ diff --git a/jc/cli.py b/jc/cli.py index 8a5100cc..cab5581c 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -215,7 +215,6 @@ Examples: Show Hidden Parsers: $ jc -hh - $ jc --about --pretty ''' return helptext_string diff --git a/man/jc.1 b/man/jc.1 index 6291f633..0cbd86e9 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,13 +1,26 @@ .TH jc 1 2022-09-07 1.21.2 "JSON Convert" .SH NAME -\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types +\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings .SH SYNOPSIS -COMMAND | jc PARSER [OPTIONS] -or "Magic" syntax: +Standard syntax: +.RS +COMMAND | \fBjc\fP [OPTIONS] PARSER + +cat FILE | \fBjc\fP [OPTIONS] PARSER + +echo STRING | \fBjc\fP [OPTIONS] PARSER +.RE + +Magic syntax: + +.RS \fBjc\fP [OPTIONS] COMMAND +\fBjc\fP [OPTIONS] /proc/ +.RE + .SH DESCRIPTION \fBjc\fP JSONifies the output of many CLI tools, file-types, and common strings for easier parsing in scripts. \fBjc\fP accepts piped input from \fBSTDIN\fP and outputs a JSON representation of the previous command's output to \fBSTDOUT\fP. Alternatively, the "Magic" syntax can be used by prepending \fBjc\fP to the command to be converted. Options can be passed to \fBjc\fP immediately before the command is given. (Note: "Magic" syntax does not support shell builtins or command aliases) @@ -912,17 +925,21 @@ If a UTC timezone can be detected in the text of the command output, the timesta .SH EXAMPLES Standard Syntax: .RS -$ dig www.google.com | jc \fB--dig\fP \fB-p\fP +$ dig www.google.com | jc \fB-p\fP \fB--dig\fP + +$ cat /proc/meminfo | jc \fB--pretty\fP \fB--proc\fP .RE Magic Syntax: .RS -$ jc \fB-p\fP dig www.google.com +$ jc \fB--pretty\fP dig www.google.com + +$ jc \fB--pretty\fP /proc/meminfo .RE For parser documentation: .RS -$ jc \fB-h\fP \fB--dig\fP +$ jc \fB--help\fP \fB--dig\fP .RE .SH AUTHOR Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/templates/manpage_template b/templates/manpage_template index 03ebcd57..d6a8cc40 100644 --- a/templates/manpage_template +++ b/templates/manpage_template @@ -1,13 +1,26 @@ .TH jc 1 {{ today }} {{ jc.version}} "JSON Convert" .SH NAME -\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types +\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings .SH SYNOPSIS -COMMAND | jc PARSER [OPTIONS] -or "Magic" syntax: +Standard syntax: +.RS +COMMAND | \fBjc\fP [OPTIONS] PARSER + +cat FILE | \fBjc\fP [OPTIONS] PARSER + +echo STRING | \fBjc\fP [OPTIONS] PARSER +.RE + +Magic syntax: + +.RS \fBjc\fP [OPTIONS] COMMAND +\fBjc\fP [OPTIONS] /proc/ +.RE + .SH DESCRIPTION \fBjc\fP JSONifies the output of many CLI tools, file-types, and common strings for easier parsing in scripts. \fBjc\fP accepts piped input from \fBSTDIN\fP and outputs a JSON representation of the previous command's output to \fBSTDOUT\fP. Alternatively, the "Magic" syntax can be used by prepending \fBjc\fP to the command to be converted. Options can be passed to \fBjc\fP immediately before the command is given. (Note: "Magic" syntax does not support shell builtins or command aliases) @@ -277,17 +290,21 @@ If a UTC timezone can be detected in the text of the command output, the timesta .SH EXAMPLES Standard Syntax: .RS -$ dig www.google.com | jc \fB--dig\fP \fB-p\fP +$ dig www.google.com | jc \fB-p\fP \fB--dig\fP + +$ cat /proc/meminfo | jc \fB--pretty\fP \fB--proc\fP .RE Magic Syntax: .RS -$ jc \fB-p\fP dig www.google.com +$ jc \fB--pretty\fP dig www.google.com + +$ jc \fB--pretty\fP /proc/meminfo .RE For parser documentation: .RS -$ jc \fB-h\fP \fB--dig\fP +$ jc \fB--help\fP \fB--dig\fP .RE .SH AUTHOR {{ jc.author }} ({{ jc.author_email }}) diff --git a/templates/readme_template b/templates/readme_template index 6e98f351..9a5c2c1a 100644 --- a/templates/readme_template +++ b/templates/readme_template @@ -133,7 +133,9 @@ on Github. `jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. ```bash -COMMAND | jc PARSER [OPTIONS] +COMMAND | jc [OPTIONS] PARSER +cat FILE | jc [OPTIONS] PARSER +echo STRING | jc [OPTIONS] PARSER ``` Alternatively, the "magic" syntax can be used by prepending `jc` to the command @@ -141,6 +143,7 @@ to be converted. Options can be passed to `jc` immediately before the command is given. (Note: command aliases and shell builtins are not supported) ```bash jc [OPTIONS] COMMAND +jc [OPTIONS] /proc/ ``` The JSON output can be compact (default) or pretty formatted with the `-p` @@ -418,12 +421,12 @@ that case you can suppress the warning message with the `-q` cli option or the macOS: ```bash -cat lsof.out | jc --lsof -q +cat lsof.out | jc -q --lsof ``` or Windows: ```bash -type lsof.out | jc --lsof -q +type lsof.out | jc -q --lsof ``` Tested on: @@ -467,7 +470,7 @@ documentation. ### arp ```bash -arp | jc --arp -p # or: jc -p arp +arp | jc -p --arp # or: jc -p arp ``` ```json [ @@ -506,7 +509,7 @@ cat homes.csv ... ``` ```bash -cat homes.csv | jc --csv -p +cat homes.csv | jc -p --csv ``` ```json [ @@ -547,7 +550,7 @@ cat homes.csv | jc --csv -p ``` ### /etc/hosts file ```bash -cat /etc/hosts | jc --hosts -p +cat /etc/hosts | jc -p --hosts ``` ```json [ @@ -574,7 +577,7 @@ cat /etc/hosts | jc --hosts -p ``` ### ifconfig ```bash -ifconfig | jc --ifconfig -p # or: jc -p ifconfig +ifconfig | jc -p --ifconfig # or: jc -p ifconfig ``` ```json [ @@ -632,7 +635,7 @@ Port = 50022 ForwardX11 = no ``` ```bash -cat example.ini | jc --ini -p +cat example.ini | jc -p --ini ``` ```json { @@ -654,7 +657,7 @@ cat example.ini | jc --ini -p ``` ### ls ```bash -$ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin +$ ls -l /usr/bin | jc -p --ls # or: jc -p ls -l /usr/bin ``` ```json [ @@ -690,7 +693,7 @@ $ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin ``` ### netstat ```bash -netstat -apee | jc --netstat -p # or: jc -p netstat -apee +netstat -apee | jc -p --netstat # or: jc -p netstat -apee ``` ```json [ @@ -778,7 +781,7 @@ netstat -apee | jc --netstat -p # or: jc -p netstat -apee ``` ### /etc/passwd file ```bash -cat /etc/passwd | jc --passwd -p +cat /etc/passwd | jc -p --passwd ``` ```json [ @@ -804,7 +807,7 @@ cat /etc/passwd | jc --passwd -p ``` ### ping ```bash -ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3 +ping 8.8.8.8 -c 3 | jc -p --ping # or: jc -p ping 8.8.8.8 -c 3 ``` ```json { @@ -857,7 +860,7 @@ ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3 ``` ### ps ```bash -ps axu | jc --ps -p # or: jc -p ps axu +ps axu | jc -p --ps # or: jc -p ps axu ``` ```json [ @@ -904,7 +907,7 @@ ps axu | jc --ps -p # or: jc -p ps axu ``` ### traceroute ```bash -traceroute -m 2 8.8.8.8 | jc --traceroute -p +traceroute -m 2 8.8.8.8 | jc -p --traceroute # or: jc -p traceroute -m 2 8.8.8.8 ``` ```json @@ -969,7 +972,7 @@ traceroute -m 2 8.8.8.8 | jc --traceroute -p ``` ### uptime ```bash -uptime | jc --uptime -p # or: jc -p uptime +uptime | jc -p --uptime # or: jc -p uptime ``` ```json { @@ -1014,7 +1017,7 @@ cat cd_catalog.xml ... ``` ```bash -cat cd_catalog.xml | jc --xml -p +cat cd_catalog.xml | jc -p --xml ``` ```json { @@ -1066,7 +1069,7 @@ spec: mode: ISTIO_MUTUAL ``` ```bash -cat istio.yaml | jc --yaml -p +cat istio.yaml | jc -p --yaml ``` ```json [