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:
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
20
jc/cli.py
20
jc/cli.py
@ -179,15 +179,24 @@ 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:
|
||||||
|
|
||||||
|
Standard syntax:
|
||||||
|
|
||||||
COMMAND | jc PARSER [OPTIONS]
|
COMMAND | jc PARSER [OPTIONS]
|
||||||
|
|
||||||
or magic syntax:
|
cat FILE | jc PARSER [OPTIONS]
|
||||||
|
|
||||||
|
echo STRING | jc PARSER [OPTIONS]
|
||||||
|
|
||||||
|
Magic syntax:
|
||||||
|
|
||||||
jc [OPTIONS] COMMAND
|
jc [OPTIONS] COMMAND
|
||||||
|
|
||||||
|
jc [OPTIONS] /proc/<path-to-file>
|
||||||
|
|
||||||
Parsers:
|
Parsers:
|
||||||
{parsers_string}
|
{parsers_string}
|
||||||
Options:
|
Options:
|
||||||
@ -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:
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
2
man/jc.1
2
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
|
.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
|
||||||
|
Reference in New Issue
Block a user