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 jc - JSON Convert Proc file output parser
This parser automatically identifies the Proc file and calls the This parser automatically identifies the Proc file and calls the
corresponding parser to peform the parsing. The specific parsers can also corresponding parser to peform the parsing.
be called directly, if desired and have a naming convention of
`proc-<name>` (cli) or `proc_<name>` (module). 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): Usage (cli):
$ cat /proc/meminfo | jc --proc $ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or or
$ cat /proc/meminfo | jc --proc-memifno $ cat /proc/meminfo | jc --proc-memifno

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -179,14 +179,23 @@ def helptext(show_hidden=False):
options_string = options_text(indent=4, pad=20) options_string = options_text(indent=4, pad=20)
helptext_string = f'''\ 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: 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/<path-to-file>
Parsers: Parsers:
{parsers_string} {parsers_string}
@ -195,12 +204,18 @@ Options:
Examples: Examples:
Standard Syntax: Standard Syntax:
$ dig www.google.com | jc --dig --pretty $ dig www.google.com | jc --dig --pretty
$ cat /proc/meminfo | jc --proc --pretty
Magic Syntax: Magic Syntax:
$ jc --pretty dig www.google.com $ jc --pretty dig www.google.com
$ jc --pretty /proc/meminfo
Parser Documentation: Parser Documentation:
$ jc --help --dig $ jc --help --dig
Show Hidden Parsers:
$ jc -hh
$ jc --about --pretty
''' '''
return helptext_string return helptext_string
@ -584,7 +599,6 @@ def main():
if run_command_str.startswith('/proc'): if run_command_str.startswith('/proc'):
magic_found_parser = 'proc' magic_found_parser = 'proc'
magic_stdout = open_text_file(run_command_str) 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: elif valid_command:
try: try:

View File

@ -1,14 +1,23 @@
"""jc - JSON Convert Proc file output parser """jc - JSON Convert Proc file output parser
This parser automatically identifies the Proc file and calls the This parser automatically identifies the Proc file and calls the
corresponding parser to peform the parsing. The specific parsers can also corresponding parser to peform the parsing.
be called directly, if desired and have a naming convention of
`proc-<name>` (cli) or `proc_<name>` (module). 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): Usage (cli):
$ cat /proc/meminfo | jc --proc $ cat /proc/meminfo | jc --proc
or
$ jc /proc/meminfo
or or
$ cat /proc/meminfo | jc --proc-memifno $ cat /proc/meminfo | jc --proc-memifno

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,10 @@ Usage (cli):
$ cat /proc/modules | jc --proc $ cat /proc/modules | jc --proc
or
$ jc /proc/modules
or or
$ cat /proc/modules | jc --proc-modules $ 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 .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 and file-types
.SH SYNOPSIS .SH SYNOPSIS