1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add magic syntax for /proc to docs

This commit is contained in:
Kelly Brazil
2022-09-07 12:31:17 -07:00
parent c976c3226d
commit c1f36f7455
18 changed files with 100 additions and 12 deletions

View File

@ -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-<name>` (cli) or `proc_<name>` (module).
corresponding parser to peform the parsing.
Magic syntax for converting `/proc` files is also supported by running
`jc /proc/<path to file>`. 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-<name>` (cli) or `proc_<name>` (module).
Usage (cli):
$ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or
$ cat /proc/meminfo | jc --proc-memifno

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/buddyinfo | jc --proc
or
$ jc /proc/buddyinfo
or
$ cat /proc/buddyinfo | jc --proc-buddyinfo

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/consoles | jc --proc
or
$ jc /proc/consoles
or
$ cat /proc/consoles | jc --proc-consoles

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/cpuinfo | jc --proc
or
$ jc /proc/cpuinfo
or
$ cat /proc/cpuinfo | jc --proc-cpuinfo

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/crypto | jc --proc
or
$ jc /proc/crypto
or
$ cat /proc/crypto | jc --proc-crypto

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/devices | jc --proc
or
$ jc /proc/devices
or
$ cat /proc/devices | jc --proc-devices

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or
$ cat /proc/meminfo | jc --proc-meminfo

View File

@ -9,6 +9,10 @@ Usage (cli):
$ cat /proc/modules | jc --proc
or
$ jc /proc/modules
or
$ cat /proc/modules | jc --proc-modules

View File

@ -179,15 +179,24 @@ 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:
Standard syntax:
COMMAND | jc PARSER [OPTIONS]
or magic syntax:
cat FILE | jc PARSER [OPTIONS]
echo STRING | jc PARSER [OPTIONS]
Magic syntax:
jc [OPTIONS] COMMAND
jc [OPTIONS] /proc/<path-to-file>
Parsers:
{parsers_string}
Options:
@ -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:

View File

@ -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-<name>` (cli) or `proc_<name>` (module).
corresponding parser to peform the parsing.
Magic syntax for converting `/proc` files is also supported by running
`jc /proc/<path to file>`. 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-<name>` (cli) or `proc_<name>` (module).
Usage (cli):
$ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or
$ cat /proc/meminfo | jc --proc-memifno

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/buddyinfo | jc --proc
or
$ jc /proc/buddyinfo
or
$ cat /proc/buddyinfo | jc --proc-buddyinfo

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/consoles | jc --proc
or
$ jc /proc/consoles
or
$ cat /proc/consoles | jc --proc-consoles

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/cpuinfo | jc --proc
or
$ jc /proc/cpuinfo
or
$ cat /proc/cpuinfo | jc --proc-cpuinfo

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/crypto | jc --proc
or
$ jc /proc/crypto
or
$ cat /proc/crypto | jc --proc-crypto

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/devices | jc --proc
or
$ jc /proc/devices
or
$ cat /proc/devices | jc --proc-devices

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or
$ cat /proc/meminfo | jc --proc-meminfo

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/modules | jc --proc
or
$ jc /proc/modules
or
$ cat /proc/modules | jc --proc-modules

View File

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