diff --git a/docs/parsers/proc.md b/docs/parsers/proc.md index 531d601d..d51a25d9 100644 --- a/docs/parsers/proc.md +++ b/docs/parsers/proc.md @@ -6,14 +6,23 @@ jc - JSON Convert Proc file output parser This parser automatically identifies the Proc file and calls the -corresponding parser to peform the parsing. The specific parsers can also -be called directly, if desired and have a naming convention of -`proc-` (cli) or `proc_` (module). +corresponding parser to peform the parsing. + +Magic syntax for converting `/proc` files is also supported by running +`jc /proc/`. Any `jc` options must be specified before the +`/proc` path. + +specific Proc file parsers can also be called directly, if desired and have +a naming convention of `proc-` (cli) or `proc_` (module). Usage (cli): $ cat /proc/meminfo | jc --proc +or + + $ jc /proc/meminfo + or $ cat /proc/meminfo | jc --proc-memifno diff --git a/docs/parsers/proc_buddyinfo.md b/docs/parsers/proc_buddyinfo.md index df66ef22..7bed14e5 100644 --- a/docs/parsers/proc_buddyinfo.md +++ b/docs/parsers/proc_buddyinfo.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/buddyinfo | jc --proc +or + + $ jc /proc/buddyinfo + or $ cat /proc/buddyinfo | jc --proc-buddyinfo diff --git a/docs/parsers/proc_consoles.md b/docs/parsers/proc_consoles.md index e3441ec1..db00dced 100644 --- a/docs/parsers/proc_consoles.md +++ b/docs/parsers/proc_consoles.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/consoles | jc --proc +or + + $ jc /proc/consoles + or $ cat /proc/consoles | jc --proc-consoles diff --git a/docs/parsers/proc_cpuinfo.md b/docs/parsers/proc_cpuinfo.md index 3bf9c967..39e39643 100644 --- a/docs/parsers/proc_cpuinfo.md +++ b/docs/parsers/proc_cpuinfo.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/cpuinfo | jc --proc +or + + $ jc /proc/cpuinfo + or $ cat /proc/cpuinfo | jc --proc-cpuinfo diff --git a/docs/parsers/proc_crypto.md b/docs/parsers/proc_crypto.md index 119a3378..835489d7 100644 --- a/docs/parsers/proc_crypto.md +++ b/docs/parsers/proc_crypto.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/crypto | jc --proc +or + + $ jc /proc/crypto + or $ cat /proc/crypto | jc --proc-crypto diff --git a/docs/parsers/proc_devices.md b/docs/parsers/proc_devices.md index b269b321..c5b82a06 100644 --- a/docs/parsers/proc_devices.md +++ b/docs/parsers/proc_devices.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/devices | jc --proc +or + + $ jc /proc/devices + or $ cat /proc/devices | jc --proc-devices diff --git a/docs/parsers/proc_meminfo.md b/docs/parsers/proc_meminfo.md index edf76d2e..45328325 100644 --- a/docs/parsers/proc_meminfo.md +++ b/docs/parsers/proc_meminfo.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/meminfo | jc --proc +or + + $ jc /proc/meminfo + or $ cat /proc/meminfo | jc --proc-meminfo diff --git a/docs/parsers/proc_modules.md b/docs/parsers/proc_modules.md index 6fda08cc..82833a42 100644 --- a/docs/parsers/proc_modules.md +++ b/docs/parsers/proc_modules.md @@ -9,6 +9,10 @@ Usage (cli): $ cat /proc/modules | jc --proc +or + + $ jc /proc/modules + or $ cat /proc/modules | jc --proc-modules diff --git a/jc/cli.py b/jc/cli.py index c8615f90..3077513d 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -179,14 +179,23 @@ def helptext(show_hidden=False): options_string = options_text(indent=4, pad=20) helptext_string = f'''\ -jc converts the output of many commands and file-types to JSON or YAML +jc converts the output of many commands, file-types, and strings to JSON or YAML Usage: - COMMAND | jc PARSER [OPTIONS] - or magic syntax: + Standard syntax: - jc [OPTIONS] COMMAND + COMMAND | jc PARSER [OPTIONS] + + cat FILE | jc PARSER [OPTIONS] + + echo STRING | jc PARSER [OPTIONS] + + Magic syntax: + + jc [OPTIONS] COMMAND + + jc [OPTIONS] /proc/ Parsers: {parsers_string} @@ -195,12 +204,18 @@ Options: Examples: Standard Syntax: $ dig www.google.com | jc --dig --pretty + $ cat /proc/meminfo | jc --proc --pretty Magic Syntax: $ jc --pretty dig www.google.com + $ jc --pretty /proc/meminfo Parser Documentation: $ jc --help --dig + + Show Hidden Parsers: + $ jc -hh + $ jc --about --pretty ''' return helptext_string @@ -584,7 +599,6 @@ def main(): if run_command_str.startswith('/proc'): magic_found_parser = 'proc' magic_stdout = open_text_file(run_command_str) - print(f'this is a procfile. Magic parser={magic_found_parser}, runstring={run_command_str}') elif valid_command: try: diff --git a/jc/parsers/proc.py b/jc/parsers/proc.py index 0317ff53..a4309329 100644 --- a/jc/parsers/proc.py +++ b/jc/parsers/proc.py @@ -1,14 +1,23 @@ """jc - JSON Convert Proc file output parser This parser automatically identifies the Proc file and calls the -corresponding parser to peform the parsing. The specific parsers can also -be called directly, if desired and have a naming convention of -`proc-` (cli) or `proc_` (module). +corresponding parser to peform the parsing. + +Magic syntax for converting `/proc` files is also supported by running +`jc /proc/`. Any `jc` options must be specified before the +`/proc` path. + +specific Proc file parsers can also be called directly, if desired and have +a naming convention of `proc-` (cli) or `proc_` (module). Usage (cli): $ cat /proc/meminfo | jc --proc +or + + $ jc /proc/meminfo + or $ cat /proc/meminfo | jc --proc-memifno diff --git a/jc/parsers/proc_buddyinfo.py b/jc/parsers/proc_buddyinfo.py index 3c2bd44e..1efd5680 100644 --- a/jc/parsers/proc_buddyinfo.py +++ b/jc/parsers/proc_buddyinfo.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/buddyinfo | jc --proc +or + + $ jc /proc/buddyinfo + or $ cat /proc/buddyinfo | jc --proc-buddyinfo diff --git a/jc/parsers/proc_consoles.py b/jc/parsers/proc_consoles.py index 5f517f4b..3423d0b0 100644 --- a/jc/parsers/proc_consoles.py +++ b/jc/parsers/proc_consoles.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/consoles | jc --proc +or + + $ jc /proc/consoles + or $ cat /proc/consoles | jc --proc-consoles diff --git a/jc/parsers/proc_cpuinfo.py b/jc/parsers/proc_cpuinfo.py index 0627783f..16c93892 100644 --- a/jc/parsers/proc_cpuinfo.py +++ b/jc/parsers/proc_cpuinfo.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/cpuinfo | jc --proc +or + + $ jc /proc/cpuinfo + or $ cat /proc/cpuinfo | jc --proc-cpuinfo diff --git a/jc/parsers/proc_crypto.py b/jc/parsers/proc_crypto.py index c2c9352f..f2b4fa4a 100644 --- a/jc/parsers/proc_crypto.py +++ b/jc/parsers/proc_crypto.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/crypto | jc --proc +or + + $ jc /proc/crypto + or $ cat /proc/crypto | jc --proc-crypto diff --git a/jc/parsers/proc_devices.py b/jc/parsers/proc_devices.py index deec4866..4d2a4441 100644 --- a/jc/parsers/proc_devices.py +++ b/jc/parsers/proc_devices.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/devices | jc --proc +or + + $ jc /proc/devices + or $ cat /proc/devices | jc --proc-devices diff --git a/jc/parsers/proc_meminfo.py b/jc/parsers/proc_meminfo.py index daed6188..7b069f12 100644 --- a/jc/parsers/proc_meminfo.py +++ b/jc/parsers/proc_meminfo.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/meminfo | jc --proc +or + + $ jc /proc/meminfo + or $ cat /proc/meminfo | jc --proc-meminfo diff --git a/jc/parsers/proc_modules.py b/jc/parsers/proc_modules.py index 1404c66a..f74e9539 100644 --- a/jc/parsers/proc_modules.py +++ b/jc/parsers/proc_modules.py @@ -4,6 +4,10 @@ Usage (cli): $ cat /proc/modules | jc --proc +or + + $ jc /proc/modules + or $ cat /proc/modules | jc --proc-modules diff --git a/man/jc.1 b/man/jc.1 index 33be6f91..6291f633 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2022-09-06 1.21.2 "JSON Convert" +.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 .SH SYNOPSIS