From 4825b16f07474771162b6b183d90ab3e13d40c3c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 22 Apr 2022 15:23:11 -0700 Subject: [PATCH] doc update --- README.md | 2 + docs/parsers/update_alt_gs.md | 71 +++++++++++++++ docs/parsers/update_alt_q.md | 157 ++++++++++++++++++++++++++++++++++ man/jc.1 | 12 ++- 4 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 docs/parsers/update_alt_gs.md create mode 100644 docs/parsers/update_alt_q.md diff --git a/README.md b/README.md index 68559164..6b89c393 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,8 @@ option. - `--ufw` enables the `ufw status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw)) - `--ufw-appinfo` enables the `ufw app info [application]` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo)) - `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname)) +- `--update-alt-gs` enables the `update-alternatives --get-selections` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_gs)) +- `--update-alt-q` enables the `update-alternatives --query` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q)) - `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower)) - `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime)) - `--vmstat` enables the `vmstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat)) diff --git a/docs/parsers/update_alt_gs.md b/docs/parsers/update_alt_gs.md new file mode 100644 index 00000000..61496af2 --- /dev/null +++ b/docs/parsers/update_alt_gs.md @@ -0,0 +1,71 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.update\_alt\_gs + +jc - JSON Convert `update-alternatives --get-selections` command output parser + +Usage (cli): + + $ update-alternatives --get-selections | jc --update-alt-gs + + or + + $ jc update-alternatives --get-selections + +Usage (module): + + import jc + result = jc.parse('update-alt-gs', + update_alternatives_get_selections_command_output) + +Schema: + + [ + { + "name": string, + "status": string, + "current": string + } + ] + +Examples: + + $ update-alternatives --get-selections | jc --update-alt-gs -p + [ + { + "name": "arptables", + "status": "auto", + "current": "/usr/sbin/arptables-nft" + }, + { + "name": "awk", + "status": "auto", + "current": "/usr/bin/gawk" + } + ] + + + +### parse + +```python +def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict] +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of Dictionaries. Raw or processed structured data. + +### Parser Information +Compatibility: linux + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/update_alt_q.md b/docs/parsers/update_alt_q.md new file mode 100644 index 00000000..d9737704 --- /dev/null +++ b/docs/parsers/update_alt_q.md @@ -0,0 +1,157 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.update\_alt\_q + +jc - JSON Convert `update-alternatives --query` command output parser + +Usage (cli): + + $ update-alternatives --query | jc --update-alt-q + + or + + $ jc update-alternatives --query + +Usage (module): + + import jc + result = jc.parse('update_alt_q', + update_alternatives_query_command_output) + +Schema: + + { + "name": string, + "link": string, + "slaves": [ + { + "name": string, + "path": string + } + ], + "status": string, + "best": string, + "value": string, # (null if 'none') + "alternatives": [ + { + "name": string, + "priority": integer, + "slaves": [ + { + "name": string, + "path": string + } + ] + } + ] + } + +Examples: + + $ update-alternatives --query editor | jc --update-alt-q -p + { + "name": "editor", + "link": "/usr/bin/editor", + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/editor.1.gz" + }, + { + "name": "editor.da.1.gz", + "path": "/usr/share/man/da/man1/editor.1.gz" + } + ], + "status": "auto", + "best": "/bin/nano", + "value": "/bin/nano", + "alternatives": [ + { + "name": "/bin/ed", + "priority": -100, + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/ed.1.gz" + } + ] + }, + { + "name": "/bin/nano", + "priority": 40, + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/nano.1.gz" + } + ] + } + ] + } + + $ update-alternatives --query | jc --update-alt-q -p -r + { + "name": "editor", + "link": "/usr/bin/editor", + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/editor.1.gz" + }, + { + "name": "editor.da.1.gz", + "path": "/usr/share/man/da/man1/editor.1.gz" + } + ], + "status": "auto", + "best": "/bin/nano", + "value": "/bin/nano", + "alternatives": [ + { + "name": "/bin/ed", + "priority": "-100", + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/ed.1.gz" + } + ] + }, + { + "name": "/bin/nano", + "priority": "40", + "slaves": [ + { + "name": "editor.1.gz", + "path": "/usr/share/man/man1/nano.1.gz" + } + ] + } + ] + } + + + +### parse + +```python +def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + +Returns: + + Dictionary. Raw or processed structured data. + +### Parser Information +Compatibility: linux + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/man/jc.1 b/man/jc.1 index 62f12bee..b4c9910c 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2022-04-20 1.18.7 "JSON Convert" +.TH jc 1 2022-04-22 1.18.7 "JSON Convert" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -442,6 +442,16 @@ Key/Value file parser \fB--uname\fP `uname -a` command parser +.TP +.B +\fB--update-alt-gs\fP +`update-alternatives --get-selections` command parser + +.TP +.B +\fB--update-alt-q\fP +`update-alternatives --query` command parser + .TP .B \fB--upower\fP