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
|
||||
|
||||
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
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/buddyinfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/buddyinfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/buddyinfo | jc --proc-buddyinfo
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/consoles | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/consoles
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/consoles | jc --proc-consoles
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/cpuinfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/cpuinfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/cpuinfo | jc --proc-cpuinfo
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/crypto | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/crypto
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/crypto | jc --proc-crypto
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/devices | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/devices
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/devices | jc --proc-devices
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/meminfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/meminfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/meminfo | jc --proc-meminfo
|
||||
|
@ -9,6 +9,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/modules | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/modules
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/modules | jc --proc-modules
|
||||
|
24
jc/cli.py
24
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/<path-to-file>
|
||||
|
||||
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:
|
||||
|
@ -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
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/buddyinfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/buddyinfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/buddyinfo | jc --proc-buddyinfo
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/consoles | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/consoles
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/consoles | jc --proc-consoles
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/cpuinfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/cpuinfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/cpuinfo | jc --proc-cpuinfo
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/crypto | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/crypto
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/crypto | jc --proc-crypto
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/devices | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/devices
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/devices | jc --proc-devices
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/meminfo | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/meminfo
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/meminfo | jc --proc-meminfo
|
||||
|
@ -4,6 +4,10 @@ Usage (cli):
|
||||
|
||||
$ cat /proc/modules | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/modules
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/modules | jc --proc-modules
|
||||
|
Reference in New Issue
Block a user