diff --git a/CHANGELOG b/CHANGELOG index 5859fd1f..af9e8ad9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,8 @@ jc changelog 20231128 v1.24.0 -- Add `apkindex` parser for Alpine Linux Package Index files -- Add `deb-packages-index` parser for Debian/Ubuntu Package Index files +- Add `pkg-index-alpine` parser for Alpine Linux Package Index files +- Add `pkg-index-deb` parser for Debian/Ubuntu Package Index files - Add `debconf-show` command parser - Add `swapon` command parser - Add `tune2fs` command parser diff --git a/README.md b/README.md index aba68cd3..1240cb2a 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,6 @@ option. | `--acpi` | `acpi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) | | `--airport` | `airport -I` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport) | | `--airport-s` | `airport -s` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) | -| `--apkindex` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/apkindex) | | `--arp` | `arp` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) | | `--asciitable` | ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable) | | `--asciitable-m` | multi-line ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) | @@ -254,6 +253,7 @@ option. | `--ping-s` | `ping` and `ping6` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s) | | `--pip-list` | `pip list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list) | | `--pip-show` | `pip show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show) | +| `--pkg-index-alpine` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_alpine) | | `--plist` | PLIST file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/plist) | | `--postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) | | `--proc` | `/proc/` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/proc) | diff --git a/completions/jc_bash_completion.sh b/completions/jc_bash_completion.sh index d27ec00a..fb4f19e8 100644 --- a/completions/jc_bash_completion.sh +++ b/completions/jc_bash_completion.sh @@ -4,7 +4,7 @@ _jc() jc_about_options jc_about_mod_options jc_help_options jc_special_options jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date debconf-show df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool) - jc_parsers=(--acpi --airport --airport-s --apkindex --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) + jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y) jc_about_options=(--about -a) jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C) diff --git a/completions/jc_zsh_completion.sh b/completions/jc_zsh_completion.sh index a04dcc82..9cae554e 100644 --- a/completions/jc_zsh_completion.sh +++ b/completions/jc_zsh_completion.sh @@ -115,12 +115,11 @@ _jc() { 'zipinfo:run "zipinfo" command with magic syntax.' 'zpool:run "zpool" command with magic syntax.' ) - jc_parsers=(--acpi --airport --airport-s --apkindex --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) + jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) jc_parsers_describe=( '--acpi:`acpi` command parser' '--airport:`airport -I` command parser' '--airport-s:`airport -s` command parser' - '--apkindex:Alpine Linux Package Index file parser' '--arp:`arp` command parser' '--asciitable:ASCII and Unicode table parser' '--asciitable-m:multi-line ASCII and Unicode table parser' @@ -214,6 +213,7 @@ _jc() { '--ping-s:`ping` and `ping6` command streaming parser' '--pip-list:`pip list` command parser' '--pip-show:`pip show` command parser' + '--pkg-index-alpine:Alpine Linux Package Index file parser' '--plist:PLIST file parser' '--postconf:`postconf -M` command parser' '--proc:`/proc/` file parser' diff --git a/jc/lib.py b/jc/lib.py index c99c6b0b..b942da38 100644 --- a/jc/lib.py +++ b/jc/lib.py @@ -15,7 +15,6 @@ parsers: List[str] = [ 'acpi', 'airport', 'airport-s', - 'apkindex', 'arp', 'asciitable', 'asciitable-m', @@ -109,6 +108,7 @@ parsers: List[str] = [ 'ping-s', 'pip-list', 'pip-show', + 'pkg-index-alpine', 'plist', 'postconf', 'proc', diff --git a/jc/parsers/iftop.py b/jc/parsers/iftop.py index d1e3ceb6..f1fd4d0f 100644 --- a/jc/parsers/iftop.py +++ b/jc/parsers/iftop.py @@ -2,10 +2,8 @@ Some of `iftop` options are supported. - Usage (cli): - $ iftop -i -t -P -s 1 | jc --iftop $ iftop -i -t -B -s1 | jc --iftop Usage (module): @@ -135,7 +133,6 @@ from numbers import Number class info: """Provides parser metadata (version, author, etc.)""" - version = "0.1" description = "`iftop` command parser" author = "Ron Green" diff --git a/jc/parsers/apkindex.py b/jc/parsers/pkg_index_alpine.py similarity index 96% rename from jc/parsers/apkindex.py rename to jc/parsers/pkg_index_alpine.py index e1b83b73..1523a39e 100644 --- a/jc/parsers/apkindex.py +++ b/jc/parsers/pkg_index_alpine.py @@ -2,12 +2,12 @@ Usage (cli): - $ jc --apkindex < APKINDEX + $ cat APKINDEX | jc --pkg-index-alpine Usage (module): import jc - result = jc.parse('apkindex', apkindex_output) + result = jc.parse('pkg_index_alpine', pkg_index_alpine_output) Schema: @@ -44,7 +44,7 @@ Schema: Example: - $ jc --apkindex < APKINDEX + $ cat APKINDEX | jc --pkg-index-alpine [ { "checksum": "Q1znBl9k+RKgY6gl5Eg3iz73KZbLY=", @@ -74,7 +74,7 @@ Example: } ] - $ jc --apkindex --raw < APKINDEX + $ cat APKINDEX | jc --pkg-index-alpine --raw [ { "C": "Q1znBl9k+RKgY6gl5Eg3iz73KZbLY=", diff --git a/man/jc.1 b/man/jc.1 index 20a31933..3960b4b5 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2023-12-04 1.24.0 "JSON Convert" +.TH jc 1 2023-12-09 1.24.0 "JSON Convert" .SH NAME \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings @@ -52,11 +52,6 @@ Parsers: \fB--airport-s\fP `airport -s` command parser -.TP -.B -\fB--apkindex\fP -Alpine Linux Package Index file parser - .TP .B \fB--arp\fP @@ -522,6 +517,11 @@ PostgreSQL password file parser \fB--pip-show\fP `pip show` command parser +.TP +.B +\fB--pkg-index-alpine\fP +Alpine Linux Package Index file parser + .TP .B \fB--plist\fP diff --git a/tests/fixtures/generic/apkindex.raw.json b/tests/fixtures/generic/pkg-index-alpine-raw.json similarity index 100% rename from tests/fixtures/generic/apkindex.raw.json rename to tests/fixtures/generic/pkg-index-alpine-raw.json diff --git a/tests/fixtures/generic/apkindex.json b/tests/fixtures/generic/pkg-index-alpine.json similarity index 100% rename from tests/fixtures/generic/apkindex.json rename to tests/fixtures/generic/pkg-index-alpine.json diff --git a/tests/fixtures/generic/apkindex b/tests/fixtures/generic/pkg-index-alpine.out similarity index 100% rename from tests/fixtures/generic/apkindex rename to tests/fixtures/generic/pkg-index-alpine.out diff --git a/tests/test_apkindex.py b/tests/test_apkindex.py index 3ef55e78..b4f8d314 100644 --- a/tests/test_apkindex.py +++ b/tests/test_apkindex.py @@ -2,7 +2,7 @@ import os import unittest import json from typing import Dict -from jc.parsers.apkindex import parse +from jc.parsers.pkg_index_alpine import parse THIS_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -15,11 +15,11 @@ class Apkindex(unittest.TestCase): def setUpClass(cls): fixtures = { 'normal': ( - 'fixtures/generic/apkindex', - 'fixtures/generic/apkindex.json'), + 'fixtures/generic/pkg-index-alpine.out', + 'fixtures/generic/pkg-index-alpine.json'), 'raw': ( - 'fixtures/generic/apkindex', - 'fixtures/generic/apkindex.raw.json') + 'fixtures/generic/pkg-index-alpine.out', + 'fixtures/generic/pkg-index-alpine-raw.json') } for file, filepaths in fixtures.items(): @@ -29,16 +29,16 @@ class Apkindex(unittest.TestCase): cls.f_json[file] = json.loads(b.read()) - def test_apkindex_nodata(self): + def test_pkg_index_alpine_nodata(self): """ - Test 'apkindex' with no data + Test 'pkg-index-alpine' with no data """ self.assertEqual(parse('', quiet=True), []) - def test_apkindex(self): + def test_pkg_index_alpine(self): """ - Test 'apkindex' normal output + Test 'pkg-index-alpine' normal output """ self.assertEqual( parse(self.f_in['normal'], quiet=True), @@ -46,9 +46,9 @@ class Apkindex(unittest.TestCase): ) - def test_apkindex_raw(self): + def test_pkg_index_alpine_raw(self): """ - Test 'apkindex' raw output + Test 'pkg-index-alpine' raw output """ self.assertEqual( parse(self.f_in['raw'], quiet=True, raw=True),