1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

doc updates

This commit is contained in:
Kelly Brazil
2020-07-09 16:18:33 -07:00
parent e2bac97d56
commit c6baf42e72
3 changed files with 94 additions and 7 deletions

View File

@ -44,6 +44,7 @@ pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
pydocmd simple jc.parsers.shadow+ > ../docs/parsers/shadow.md pydocmd simple jc.parsers.shadow+ > ../docs/parsers/shadow.md
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
pydocmd simple jc.parsers.stat+ > ../docs/parsers/stat.md pydocmd simple jc.parsers.stat+ > ../docs/parsers/stat.md
pydocmd simple jc.parsers.sysctl+ > ../docs/parsers/sysctl.md
pydocmd simple jc.parsers.systemctl+ > ../docs/parsers/systemctl.md pydocmd simple jc.parsers.systemctl+ > ../docs/parsers/systemctl.md
pydocmd simple jc.parsers.systemctl_lj+ > ../docs/parsers/systemctl_lj.md pydocmd simple jc.parsers.systemctl_lj+ > ../docs/parsers/systemctl_lj.md
pydocmd simple jc.parsers.systemctl_ls+ > ../docs/parsers/systemctl_ls.md pydocmd simple jc.parsers.systemctl_ls+ > ../docs/parsers/systemctl_ls.md

86
docs/parsers/sysctl.md Normal file
View File

@ -0,0 +1,86 @@
# jc.parsers.sysctl
jc - JSON CLI output utility sysctl -a Parser
Usage:
specify --sysctl as the first argument if the piped input is coming from sysctl -a
Note: since sysctl output is not easily parsable only a very simple key/value object
will be output. An attempt is made to covert obvious integers and floats. If no
conversion is desired, use the -r (raw) option.
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ sysctl | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
...
}
$ sysctl | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
...
}
## info
```python
info(self, /, *args, **kwargs)
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
[
{
"foo": string/integer/float,
"bar": string/integer/float,
"baz": string/integer/float
}
]
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

View File

@ -5,12 +5,12 @@ Usage:
specify --sysctl as the first argument if the piped input is coming from sysctl -a specify --sysctl as the first argument if the piped input is coming from sysctl -a
Note: since sysctl output is not easily parsable only a very simple key/value object Note: since sysctl output is not easily parsable only a very simple key/value object
will be output. An attempt is made to covert obvious integers. If no conversion will be output. An attempt is made to covert obvious integers and floats. If no
is desired, use the -r (raw) option in jc. conversion is desired, use the -r (raw) option.
Compatibility: Compatibility:
'linux', 'darwin', 'aix', 'freebsd' 'linux', 'darwin', 'freebsd'
Examples: Examples:
@ -49,7 +49,7 @@ class info():
# details = 'enter any other details here' # details = 'enter any other details here'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd # compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'aix', 'freebsd'] compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['sysctl'] magic_commands = ['sysctl']
@ -70,9 +70,9 @@ def process(proc_data):
[ [
{ {
"foo": string/integer, "foo": string/integer/float,
"bar": string/integer, "bar": string/integer/float,
"baz": string/integer "baz": string/integer/float
} }
] ]
""" """