1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/man/jc.1

1607 lines
25 KiB
Groff
Raw Normal View History

.TH jc 1 2024-02-27 1.25.2 "JSON Convert"
2021-07-19 12:08:50 -07:00
.SH NAME
2023-01-27 14:47:08 -08:00
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
and strings
2021-07-19 12:08:50 -07:00
.SH SYNOPSIS
2022-09-07 13:56:16 -07:00
Standard syntax:
2021-07-19 12:08:50 -07:00
2022-09-07 13:56:16 -07:00
.RS
2023-01-27 11:31:16 -08:00
COMMAND | \fBjc\fP [SLICE] [OPTIONS] PARSER
2022-09-07 13:56:16 -07:00
2023-01-27 11:31:16 -08:00
cat FILE | \fBjc\fP [SLICE] [OPTIONS] PARSER
2022-09-07 13:56:16 -07:00
2023-01-27 11:31:16 -08:00
echo STRING | \fBjc\fP [SLICE] [OPTIONS] PARSER
2022-09-07 13:56:16 -07:00
.RE
Magic syntax:
.RS
2023-01-27 11:31:16 -08:00
\fBjc\fP [SLICE] [OPTIONS] COMMAND
2021-07-19 12:08:50 -07:00
2023-01-27 11:31:16 -08:00
\fBjc\fP [SLICE] [OPTIONS] /proc/<path-to-procfile>
2022-09-07 13:56:16 -07:00
.RE
2021-07-19 12:08:50 -07:00
.SH DESCRIPTION
2023-01-27 14:47:08 -08:00
\fBjc\fP JSONifies the output of many CLI tools, file-types, and common strings
for easier parsing in scripts. \fBjc\fP accepts piped input from \fBSTDIN\fP and
outputs a JSON representation of the previous command's output to \fBSTDOUT\fP.
Alternatively, the "Magic" syntax can be used by prepending \fBjc\fP to the
command to be converted. Options can be passed to \fBjc\fP immediately before
the command is given. (Note: "Magic" syntax does not support shell builtins or
command aliases)
2021-07-19 12:08:50 -07:00
.SH OPTIONS
.B
Parsers:
.RS
.TP
.B
\fB--acpi\fP
`acpi` command parser
.TP
.B
\fB--airport\fP
`airport -I` command parser
.TP
.B
\fB--airport-s\fP
`airport -s` command parser
.TP
.B
\fB--apt-cache-show\fP
`apt-cache show` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--arp\fP
`arp` command parser
2022-03-22 12:25:59 -07:00
.TP
.B
\fB--asciitable\fP
ASCII and Unicode table parser
2022-03-22 07:05:14 -07:00
.TP
.B
\fB--asciitable-m\fP
multi-line ASCII and Unicode table parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--blkid\fP
`blkid` command parser
2023-04-16 11:46:21 -07:00
.TP
.B
\fB--bluetoothctl\fP
`bluetoothctl` command parser
2022-12-13 12:13:27 -08:00
.TP
.B
\fB--cbt\fP
2022-12-16 12:54:07 -08:00
`cbt` (Google Bigtable) command parser
2022-12-13 12:13:27 -08:00
2022-08-12 10:16:15 -07:00
.TP
.B
\fB--cef\fP
CEF string parser
2022-08-20 13:30:39 -07:00
.TP
.B
\fB--cef-s\fP
CEF string streaming parser
2023-04-29 16:34:23 -07:00
.TP
.B
\fB--certbot\fP
`certbot` command parser
2022-05-11 16:12:29 -07:00
.TP
.B
\fB--chage\fP
`chage --list` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--cksum\fP
`cksum` and `sum` command parser
2022-11-20 20:45:22 -08:00
.TP
.B
\fB--clf\fP
Common and Combined Log Format file parser
2022-11-20 20:45:22 -08:00
2022-11-21 16:54:13 -08:00
.TP
.B
\fB--clf-s\fP
Common and Combined Log Format file streaming parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--crontab\fP
`crontab` command and file parser
.TP
.B
\fB--crontab-u\fP
`crontab` file parser with user support
.TP
.B
\fB--csv\fP
CSV file parser
2021-10-24 13:10:47 -07:00
.TP
.B
\fB--csv-s\fP
CSV file streaming parser
2024-02-04 12:03:48 -08:00
.TP
.B
\fB--curl-head\fP
`curl --head` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--date\fP
`date` command parser
.TP
.B
\fB--datetime-iso\fP
ISO 8601 Datetime string parser
2023-11-23 14:52:06 -08:00
.TP
.B
\fB--debconf-show\fP
`debconf-show` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--df\fP
`df` command parser
.TP
.B
\fB--dig\fP
`dig` command parser
.TP
.B
\fB--dir\fP
`dir` command parser
.TP
.B
\fB--dmidecode\fP
`dmidecode` command parser
.TP
.B
\fB--dpkg-l\fP
`dpkg -l` command parser
.TP
.B
\fB--du\fP
`du` command parser
2024-02-05 11:35:59 -08:00
.TP
.B
\fB--efibootmgr\fP
`efibootmgr` command parser
2022-07-19 13:02:09 -07:00
.TP
.B
\fB--email-address\fP
Email Address string parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--env\fP
`env` command parser
.TP
.B
\fB--file\fP
`file` command parser
.TP
.B
\fB--find\fP
`find` command parser
2022-11-01 13:15:31 -07:00
.TP
.B
\fB--findmnt\fP
`findmnt` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--finger\fP
`finger` command parser
.TP
.B
\fB--free\fP
`free` command parser
.TP
.B
\fB--fstab\fP
`/etc/fstab` file parser
2022-04-19 13:17:24 -04:00
.TP
.B
\fB--git-log\fP
`git log` command parser
2022-04-28 16:23:56 -07:00
.TP
.B
\fB--git-log-s\fP
`git log` command streaming parser
2022-11-07 13:02:55 -08:00
.TP
.B
\fB--git-ls-remote\fP
`git ls-remote` command parser
2022-06-29 18:36:06 -07:00
.TP
.B
\fB--gpg\fP
`gpg --with-colons` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--group\fP
`/etc/group` file parser
.TP
.B
\fB--gshadow\fP
`/etc/gshadow` file parser
.TP
.B
\fB--hash\fP
`hash` command parser
.TP
.B
\fB--hashsum\fP
hashsum command parser (`md5sum`, `shasum`, etc.)
.TP
.B
\fB--hciconfig\fP
`hciconfig` command parser
.TP
.B
\fB--history\fP
`history` command parser
2023-09-30 15:32:27 -07:00
.TP
.B
\fB--host\fP
`host` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--hosts\fP
`/etc/hosts` file parser
2024-02-04 12:03:48 -08:00
.TP
.B
\fB--http-headers\fP
HTTP headers parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--id\fP
`id` command parser
.TP
.B
\fB--ifconfig\fP
`ifconfig` command parser
.TP
.B
\fB--ini\fP
INI file parser
2023-01-08 19:46:13 -08:00
.TP
.B
\fB--ini-dup\fP
INI with duplicate key file parser
2021-12-01 16:12:51 -08:00
.TP
.B
\fB--iostat\fP
`iostat` command parser
2021-12-02 11:42:56 -08:00
.TP
.B
\fB--iostat-s\fP
`iostat` command streaming parser
2022-07-27 17:21:04 -07:00
.TP
.B
\fB--ip-address\fP
2022-07-28 09:03:49 -07:00
IPv4 and IPv6 Address string parser
2022-07-27 17:21:04 -07:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--iptables\fP
`iptables` command parser
.TP
.B
\fB--ip-route\fP
`ip route` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--iw-scan\fP
`iw dev [device] scan` command parser
2022-12-23 09:12:09 -08:00
.TP
.B
\fB--iwconfig\fP
`iwconfig` command parser
2022-01-02 11:00:52 -08:00
.TP
.B
\fB--jar-manifest\fP
2022-08-15 13:51:48 -07:00
Java MANIFEST.MF file parser
2022-01-02 11:00:52 -08:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--jobs\fP
`jobs` command parser
2022-07-19 15:24:38 -07:00
.TP
.B
\fB--jwt\fP
JWT string parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--kv\fP
2022-12-27 14:01:03 -08:00
Key/Value file and string parser
2021-07-19 12:08:50 -07:00
2023-12-22 09:45:43 -08:00
.TP
.B
\fB--kv-dup\fP
Key/Value with duplicate key file and string parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--last\fP
`last` and `lastb` command parser
.TP
.B
\fB--ls\fP
`ls` command parser
2021-09-10 14:27:50 -07:00
.TP
.B
\fB--ls-s\fP
`ls` command streaming parser
Dev v1.23.3 (#426) * make certificate search more robust to different line endings * use license_files instead of license_file which is deprecated * version bump * parsing extra options -e, -o, -p * fix for extra opts and different field length at option -[aeop] * test integration for extra opts -e -o -p * formatting and use ast.literal_eval instead of eval * doc update * doc update * Add a parser to parse mounted encrypted veracrypt volumes (fixes #403) * update compatibility warning message * netstat windows parser * tests * Windows route parser * tests * id should be a string * add veracrypt parser and docs * formatting * doc update * lsattr parser * Update test_lsattr.py * changed keys to lowercase * changed info * support missing data for stat * doc update * doc update * doc update * ensure compatibility warning prints even with no data * improve compatibility message * add support for dig +nsid option * New parser: srt (#415) * srt parser * changed the parser to support more complex cases * doc updates * Adding certificate request parser (#416) * Adding certificate request parser * Adding the CSR type for Windows-style CSR --------- Co-authored-by: Stg22 <stephane.for.test@gmail.com> * doc update * add csr tests * Last -x (#422) * Refactored the parser * last -x support * doc update * fix for ping on linux with missing hostname * allow less strict email decoding with a warning. * doc update * use explicit ascii decode with backslashreplace * doc update * use jc warning function instead of print for warning message * last -x shutdown fix (#423) * inject quiet setting into asn1crypto library * Parse appearance and modalias lines for mouse devices (fixes #419) (#425) The bluetoothctl device parser is implemented so that it aborts the parsing process immediately returning what it has collected so far. This is because the parser should work in hydrid way to support outputs comming from bluetoothctl devices and bluetoothctl info calls. * doc update * doc update --------- Co-authored-by: gerd <gerd.augstein@gmail.com> Co-authored-by: Jake Ob <iakopap@gmail.com> Co-authored-by: Mevaser <mevaser.rotner@gmail.com> Co-authored-by: M.R <69431152+YeahItsMeAgain@users.noreply.github.com> Co-authored-by: Stg22 <46686290+Stg22@users.noreply.github.com> Co-authored-by: Stg22 <stephane.for.test@gmail.com>
2023-06-22 01:48:23 +03:00
.TP
.B
\fB--lsattr\fP
`lsattr` command parser
2023-10-01 18:13:27 -07:00
.TP
.B
\fB--lsb-release\fP
`lsb_release` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--lsblk\fP
`lsblk` command parser
.TP
.B
\fB--lsmod\fP
`lsmod` command parser
.TP
.B
\fB--lsof\fP
`lsof` command parser
2022-10-08 09:04:21 -07:00
.TP
.B
\fB--lspci\fP
`lspci -mmv` command parser
2021-10-23 11:56:12 -07:00
.TP
.B
\fB--lsusb\fP
`lsusb` command parser
2022-07-16 20:52:19 -07:00
.TP
.B
\fB--m3u\fP
M3U and M3U8 file parser
2022-08-12 10:16:15 -07:00
.TP
.B
\fB--mdadm\fP
`mdadm` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--mount\fP
`mount` command parser
.TP
2022-03-11 14:54:06 -08:00
.B
\fB--mpstat\fP
`mpstat` command parser
.TP
2022-03-11 15:59:38 -08:00
.B
\fB--mpstat-s\fP
`mpstat` command streaming parser
.TP
2021-07-19 12:08:50 -07:00
.B
\fB--netstat\fP
`netstat` command parser
2022-02-24 20:43:20 -08:00
.TP
.B
\fB--nmcli\fP
`nmcli` command parser
2023-09-30 15:45:29 -07:00
.TP
.B
\fB--nsd-control\fP
`nsd-control` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--ntpq\fP
`ntpq -p` command parser
2022-12-13 17:31:05 -08:00
.TP
.B
\fB--openvpn\fP
openvpn-status.log file parser
2022-11-07 13:23:55 -08:00
.TP
.B
\fB--os-prober\fP
`os-prober` command parser
2023-10-01 17:42:00 -07:00
.TP
.B
\fB--os-release\fP
`/etc/os-release` file parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--passwd\fP
`/etc/passwd` file parser
2024-01-30 20:19:32 -08:00
.TP
.B
\fB--path\fP
POSIX path string parser
.TP
.B
\fB--path-list\fP
POSIX path list string parser
2022-10-08 09:04:21 -07:00
.TP
.B
\fB--pci-ids\fP
`pci.ids` file parser
2022-12-05 14:54:23 -08:00
.TP
.B
\fB--pgpass\fP
PostgreSQL password file parser
2022-03-09 14:09:58 -08:00
.TP
.B
\fB--pidstat\fP
2022-09-22 14:35:53 -07:00
`pidstat -H` command parser
2022-03-09 14:09:58 -08:00
2022-03-09 16:09:35 -08:00
.TP
.B
\fB--pidstat-s\fP
2022-09-22 14:41:40 -07:00
`pidstat -H` command streaming parser
2022-03-09 16:09:35 -08:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--ping\fP
`ping` and `ping6` command parser
2021-09-13 21:14:38 -07:00
.TP
.B
\fB--ping-s\fP
`ping` and `ping6` command streaming parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--pip-list\fP
`pip list` command parser
.TP
.B
\fB--pip-show\fP
`pip show` command parser
.TP
.B
\fB--pkg-index-apk\fP
Alpine Linux Package Index file parser
.TP
.B
\fB--pkg-index-deb\fP
Debian Package Index file parser
2022-07-31 16:14:04 -07:00
.TP
.B
\fB--plist\fP
PLIST file parser
2022-06-05 17:40:05 -07:00
.TP
.B
\fB--postconf\fP
`postconf -M` command parser
2022-09-06 10:07:19 -07:00
.TP
.B
\fB--proc\fP
`/proc/` file parser
2022-09-06 15:19:59 -07:00
.TP
.B
\fB--proc-buddyinfo\fP
`/proc/buddyinfo` file parser
2023-12-16 12:55:29 -08:00
.TP
.B
\fB--proc-cmdline\fP
`/proc/cmdline` file parser
.TP
.B
\fB--proc-consoles\fP
`/proc/consoles` file parser
2022-09-06 17:05:14 -07:00
.TP
.B
\fB--proc-cpuinfo\fP
`/proc/cpuinfo` file parser
2022-09-06 17:29:56 -07:00
.TP
.B
\fB--proc-crypto\fP
`/proc/crypto` file parser
2022-09-06 17:59:26 -07:00
.TP
.B
\fB--proc-devices\fP
`/proc/devices` file parser
2022-09-06 15:19:59 -07:00
2022-09-09 14:33:12 -07:00
.TP
.B
\fB--proc-diskstats\fP
`/proc/diskstats` file parser
2022-09-09 17:03:51 -07:00
.TP
.B
\fB--proc-filesystems\fP
`/proc/filesystems` file parser
2022-09-13 13:42:06 -07:00
.TP
.B
\fB--proc-interrupts\fP
`/proc/interrupts` file parser
2022-09-13 14:04:15 -07:00
.TP
.B
\fB--proc-iomem\fP
`/proc/iomem` file parser
2022-09-13 14:12:24 -07:00
.TP
.B
\fB--proc-ioports\fP
`/proc/ioports` file parser
2022-09-13 16:27:11 -07:00
.TP
.B
\fB--proc-loadavg\fP
`/proc/loadavg` file parser
2022-09-13 20:40:48 -07:00
.TP
.B
\fB--proc-locks\fP
`/proc/locks` file parser
2022-09-06 10:07:19 -07:00
.TP
.B
\fB--proc-meminfo\fP
2022-09-06 15:19:59 -07:00
`/proc/meminfo` file parser
2022-09-06 10:07:19 -07:00
.TP
.B
\fB--proc-modules\fP
2022-09-06 15:19:59 -07:00
`/proc/modules` file parser
2022-09-06 10:07:19 -07:00
2022-09-15 16:59:15 -07:00
.TP
.B
\fB--proc-mtrr\fP
`/proc/mtrr` file parser
2022-09-16 11:06:33 -07:00
.TP
.B
\fB--proc-pagetypeinfo\fP
`/proc/pagetypeinfo` file parser
2022-09-16 11:17:02 -07:00
.TP
.B
\fB--proc-partitions\fP
`/proc/partitions` file parser
2022-09-16 11:40:54 -07:00
.TP
.B
\fB--proc-slabinfo\fP
`/proc/slabinfo` file parser
2022-09-16 14:50:14 -07:00
.TP
.B
\fB--proc-softirqs\fP
`/proc/softirqs` file parser
2022-09-16 15:54:13 -07:00
.TP
.B
\fB--proc-stat\fP
`/proc/stat` file parser
2022-09-16 16:04:25 -07:00
.TP
.B
\fB--proc-swaps\fP
`/proc/swaps` file parser
2022-09-16 16:14:28 -07:00
.TP
.B
\fB--proc-uptime\fP
`/proc/uptime` file parser
2022-09-17 12:32:15 -07:00
.TP
.B
\fB--proc-version\fP
`/proc/version` file parser
2022-09-17 13:26:10 -07:00
.TP
.B
\fB--proc-vmallocinfo\fP
`/proc/vmallocinfo` file parser
2022-09-17 13:34:40 -07:00
.TP
.B
\fB--proc-vmstat\fP
`/proc/vmstat` file parser
2022-09-17 17:39:16 -07:00
.TP
.B
\fB--proc-zoneinfo\fP
`/proc/zoneinfo` file parser
2022-09-26 13:32:33 -07:00
.TP
.B
\fB--proc-driver-rtc\fP
`/proc/driver/rtc` file parser
2022-09-19 16:50:01 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-arp\fP
`/proc/net/arp` file parser
2022-09-19 16:50:01 -07:00
2022-09-19 17:49:18 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-dev\fP
`/proc/net/dev` file parser
2022-09-19 17:49:18 -07:00
2022-09-19 18:33:30 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-dev-mcast\fP
`/proc/net/dev_mcast` file parser
2022-09-19 18:33:30 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-if-inet6\fP
`/proc/net/if_inet6` file parser
2022-09-16 10:02:44 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-igmp\fP
`/proc/net/igmp` file parser
2022-09-16 10:02:44 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-igmp6\fP
`/proc/net/igmp6` file parser
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-ipv6-route\fP
`/proc/net/ipv6_route` file parser
2022-09-25 09:03:38 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-netlink\fP
`/proc/net/netlink` file parser
2022-09-25 09:03:38 -07:00
2022-09-25 09:57:48 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-netstat\fP
`/proc/net/netstat` file parser
2022-09-25 09:57:48 -07:00
2022-09-25 12:09:01 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-packet\fP
`/proc/net/packet` file parser
2022-09-25 12:09:01 -07:00
2022-09-25 13:02:25 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-protocols\fP
`/proc/net/protocols` file parser
2022-09-25 13:02:25 -07:00
2022-09-25 13:44:29 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-route\fP
`/proc/net/route` file parser
2022-09-25 13:44:29 -07:00
.TP
.B
\fB--proc-net-tcp\fP
`/proc/net/tcp` and `/proc/net/tcp6` file parser
2022-09-25 18:16:54 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-net-unix\fP
`/proc/net/unix` file parser
2022-09-25 18:16:54 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-fdinfo\fP
`/proc/<pid>/fdinfo/<fd>` file parser
2022-09-25 18:16:54 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-io\fP
`/proc/<pid>/io` file parser
2022-09-25 18:16:54 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-maps\fP
`/proc/<pid>/maps` file parser
2022-09-25 19:36:12 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-mountinfo\fP
`/proc/<pid>/mountinfo` file parser
2022-09-25 19:36:12 -07:00
2022-09-25 20:00:44 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-numa-maps\fP
`/proc/<pid>/numa_maps` file parser
2022-09-25 20:00:44 -07:00
2022-09-25 20:14:53 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-smaps\fP
`/proc/<pid>/smaps` file parser
2022-09-25 20:14:53 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-stat\fP
`/proc/<pid>/stat` file parser
2022-09-26 13:16:18 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-statm\fP
`/proc/<pid>/statm` file parser
2022-09-26 13:16:18 -07:00
2022-09-26 13:28:21 -07:00
.TP
.B
2022-09-26 13:30:52 -07:00
\fB--proc-pid-status\fP
`/proc/<pid>/status` file parser
2022-09-26 13:28:21 -07:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--ps\fP
`ps` command parser
.TP
.B
\fB--resolve-conf\fP
`/etc/resolve.conf` file parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--route\fP
`route` command parser
.TP
.B
\fB--rpm-qi\fP
`rpm -qi` command parser
2022-02-01 17:57:12 -08:00
.TP
.B
\fB--rsync\fP
`rsync` command parser
2022-02-02 15:58:29 -08:00
.TP
.B
\fB--rsync-s\fP
`rsync` command streaming parser
2022-11-04 16:03:39 -07:00
.TP
.B
\fB--semver\fP
Semantic Version string parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--sfdisk\fP
`sfdisk` command parser
.TP
.B
\fB--shadow\fP
`/etc/shadow` file parser
Dev v1.23.3 (#426) * make certificate search more robust to different line endings * use license_files instead of license_file which is deprecated * version bump * parsing extra options -e, -o, -p * fix for extra opts and different field length at option -[aeop] * test integration for extra opts -e -o -p * formatting and use ast.literal_eval instead of eval * doc update * doc update * Add a parser to parse mounted encrypted veracrypt volumes (fixes #403) * update compatibility warning message * netstat windows parser * tests * Windows route parser * tests * id should be a string * add veracrypt parser and docs * formatting * doc update * lsattr parser * Update test_lsattr.py * changed keys to lowercase * changed info * support missing data for stat * doc update * doc update * doc update * ensure compatibility warning prints even with no data * improve compatibility message * add support for dig +nsid option * New parser: srt (#415) * srt parser * changed the parser to support more complex cases * doc updates * Adding certificate request parser (#416) * Adding certificate request parser * Adding the CSR type for Windows-style CSR --------- Co-authored-by: Stg22 <stephane.for.test@gmail.com> * doc update * add csr tests * Last -x (#422) * Refactored the parser * last -x support * doc update * fix for ping on linux with missing hostname * allow less strict email decoding with a warning. * doc update * use explicit ascii decode with backslashreplace * doc update * use jc warning function instead of print for warning message * last -x shutdown fix (#423) * inject quiet setting into asn1crypto library * Parse appearance and modalias lines for mouse devices (fixes #419) (#425) The bluetoothctl device parser is implemented so that it aborts the parsing process immediately returning what it has collected so far. This is because the parser should work in hydrid way to support outputs comming from bluetoothctl devices and bluetoothctl info calls. * doc update * doc update --------- Co-authored-by: gerd <gerd.augstein@gmail.com> Co-authored-by: Jake Ob <iakopap@gmail.com> Co-authored-by: Mevaser <mevaser.rotner@gmail.com> Co-authored-by: M.R <69431152+YeahItsMeAgain@users.noreply.github.com> Co-authored-by: Stg22 <46686290+Stg22@users.noreply.github.com> Co-authored-by: Stg22 <stephane.for.test@gmail.com>
2023-06-22 01:48:23 +03:00
.TP
.B
\fB--srt\fP
SRT file parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--ss\fP
`ss` command parser
2023-01-22 10:37:27 -08:00
.TP
.B
\fB--ssh-conf\fP
2023-01-22 12:44:16 -08:00
`ssh` config file and `ssh -G` command parser
2023-01-22 10:37:27 -08:00
2022-10-31 09:22:39 -07:00
.TP
.B
\fB--sshd-conf\fP
2023-01-22 12:44:16 -08:00
`sshd` config file and `sshd -T` command parser
2022-10-31 09:22:39 -07:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--stat\fP
`stat` command parser
2022-01-06 11:00:53 -08:00
.TP
.B
\fB--stat-s\fP
`stat` command streaming parser
2023-11-28 11:23:47 -08:00
.TP
.B
\fB--swapon\fP
`swapon` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--sysctl\fP
`sysctl` command parser
2022-08-16 16:33:50 -07:00
.TP
.B
\fB--syslog\fP
Syslog RFC 5424 string parser
.TP
.B
\fB--syslog-s\fP
Syslog RFC 5424 string streaming parser
2022-08-12 10:16:15 -07:00
.TP
.B
\fB--syslog-bsd\fP
Syslog RFC 3164 string parser
.TP
.B
2022-08-16 16:33:50 -07:00
\fB--syslog-bsd-s\fP
Syslog RFC 3164 string streaming parser
2022-08-12 10:16:15 -07:00
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--systemctl\fP
`systemctl` command parser
.TP
.B
\fB--systemctl-lj\fP
`systemctl list-jobs` command parser
.TP
.B
\fB--systemctl-ls\fP
`systemctl list-sockets` command parser
.TP
.B
\fB--systemctl-luf\fP
`systemctl list-unit-files` command parser
.TP
.B
\fB--systeminfo\fP
`systeminfo` command parser
.TP
.B
\fB--time\fP
`/usr/bin/time` command parser
.TP
.B
\fB--timedatectl\fP
`timedatectl status` command parser
2022-05-25 10:31:41 -07:00
2022-07-23 12:43:17 -07:00
.TP
.B
\fB--timestamp\fP
2022-08-04 11:43:49 -07:00
Unix Epoch Timestamp string parser
2022-07-23 12:43:17 -07:00
2023-01-05 11:27:49 -08:00
.TP
.B
\fB--toml\fP
TOML file parser
2022-05-25 10:31:41 -07:00
.TP
.B
\fB--top\fP
`top -b` command parser
2022-05-27 13:34:07 -07:00
.TP
.B
\fB--top-s\fP
`top -b` command streaming parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--tracepath\fP
`tracepath` and `tracepath6` command parser
.TP
.B
\fB--traceroute\fP
`traceroute` and `traceroute6` command parser
2023-11-23 11:49:04 -08:00
.TP
.B
\fB--tune2fs\fP
`tune2fs -l` command parser
2022-10-08 09:04:21 -07:00
.TP
.B
\fB--udevadm\fP
`udevadm info` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--ufw\fP
`ufw status` command parser
.TP
.B
\fB--ufw-appinfo\fP
`ufw app info [application]` command parser
.TP
.B
\fB--uname\fP
`uname -a` command parser
2022-04-22 15:23:11 -07:00
.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
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--upower\fP
`upower` command parser
.TP
.B
\fB--uptime\fP
`uptime` command parser
2022-07-19 13:02:09 -07:00
.TP
.B
\fB--url\fP
URL string parser
2023-01-27 11:31:16 -08:00
.TP
.B
\fB--ver\fP
Version string parser
Dev v1.23.3 (#426) * make certificate search more robust to different line endings * use license_files instead of license_file which is deprecated * version bump * parsing extra options -e, -o, -p * fix for extra opts and different field length at option -[aeop] * test integration for extra opts -e -o -p * formatting and use ast.literal_eval instead of eval * doc update * doc update * Add a parser to parse mounted encrypted veracrypt volumes (fixes #403) * update compatibility warning message * netstat windows parser * tests * Windows route parser * tests * id should be a string * add veracrypt parser and docs * formatting * doc update * lsattr parser * Update test_lsattr.py * changed keys to lowercase * changed info * support missing data for stat * doc update * doc update * doc update * ensure compatibility warning prints even with no data * improve compatibility message * add support for dig +nsid option * New parser: srt (#415) * srt parser * changed the parser to support more complex cases * doc updates * Adding certificate request parser (#416) * Adding certificate request parser * Adding the CSR type for Windows-style CSR --------- Co-authored-by: Stg22 <stephane.for.test@gmail.com> * doc update * add csr tests * Last -x (#422) * Refactored the parser * last -x support * doc update * fix for ping on linux with missing hostname * allow less strict email decoding with a warning. * doc update * use explicit ascii decode with backslashreplace * doc update * use jc warning function instead of print for warning message * last -x shutdown fix (#423) * inject quiet setting into asn1crypto library * Parse appearance and modalias lines for mouse devices (fixes #419) (#425) The bluetoothctl device parser is implemented so that it aborts the parsing process immediately returning what it has collected so far. This is because the parser should work in hydrid way to support outputs comming from bluetoothctl devices and bluetoothctl info calls. * doc update * doc update --------- Co-authored-by: gerd <gerd.augstein@gmail.com> Co-authored-by: Jake Ob <iakopap@gmail.com> Co-authored-by: Mevaser <mevaser.rotner@gmail.com> Co-authored-by: M.R <69431152+YeahItsMeAgain@users.noreply.github.com> Co-authored-by: Stg22 <46686290+Stg22@users.noreply.github.com> Co-authored-by: Stg22 <stephane.for.test@gmail.com>
2023-06-22 01:48:23 +03:00
.TP
.B
\fB--veracrypt\fP
`veracrypt` command parser
2021-09-22 14:38:13 -07:00
.TP
.B
\fB--vmstat\fP
`vmstat` command parser
.TP
.B
\fB--vmstat-s\fP
`vmstat` command streaming parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--w\fP
`w` command parser
.TP
.B
\fB--wc\fP
`wc` command parser
.TP
.B
\fB--who\fP
`who` command parser
.TP
.B
2022-07-05 15:07:10 -07:00
\fB--x509-cert\fP
X.509 PEM and DER certificate file parser
2021-07-19 12:08:50 -07:00
Dev v1.23.3 (#426) * make certificate search more robust to different line endings * use license_files instead of license_file which is deprecated * version bump * parsing extra options -e, -o, -p * fix for extra opts and different field length at option -[aeop] * test integration for extra opts -e -o -p * formatting and use ast.literal_eval instead of eval * doc update * doc update * Add a parser to parse mounted encrypted veracrypt volumes (fixes #403) * update compatibility warning message * netstat windows parser * tests * Windows route parser * tests * id should be a string * add veracrypt parser and docs * formatting * doc update * lsattr parser * Update test_lsattr.py * changed keys to lowercase * changed info * support missing data for stat * doc update * doc update * doc update * ensure compatibility warning prints even with no data * improve compatibility message * add support for dig +nsid option * New parser: srt (#415) * srt parser * changed the parser to support more complex cases * doc updates * Adding certificate request parser (#416) * Adding certificate request parser * Adding the CSR type for Windows-style CSR --------- Co-authored-by: Stg22 <stephane.for.test@gmail.com> * doc update * add csr tests * Last -x (#422) * Refactored the parser * last -x support * doc update * fix for ping on linux with missing hostname * allow less strict email decoding with a warning. * doc update * use explicit ascii decode with backslashreplace * doc update * use jc warning function instead of print for warning message * last -x shutdown fix (#423) * inject quiet setting into asn1crypto library * Parse appearance and modalias lines for mouse devices (fixes #419) (#425) The bluetoothctl device parser is implemented so that it aborts the parsing process immediately returning what it has collected so far. This is because the parser should work in hydrid way to support outputs comming from bluetoothctl devices and bluetoothctl info calls. * doc update * doc update --------- Co-authored-by: gerd <gerd.augstein@gmail.com> Co-authored-by: Jake Ob <iakopap@gmail.com> Co-authored-by: Mevaser <mevaser.rotner@gmail.com> Co-authored-by: M.R <69431152+YeahItsMeAgain@users.noreply.github.com> Co-authored-by: Stg22 <46686290+Stg22@users.noreply.github.com> Co-authored-by: Stg22 <stephane.for.test@gmail.com>
2023-06-22 01:48:23 +03:00
.TP
.B
\fB--x509-csr\fP
X.509 PEM and DER certificate request file parser
2022-07-05 13:33:57 -07:00
.TP
.B
2022-07-05 15:07:10 -07:00
\fB--xml\fP
XML file parser
2022-07-05 13:33:57 -07:00
2022-02-14 09:14:46 -08:00
.TP
.B
\fB--xrandr\fP
`xrandr` command parser
2021-07-19 12:08:50 -07:00
.TP
.B
\fB--yaml\fP
YAML file parser
2021-12-21 12:14:20 -08:00
.TP
.B
\fB--zipinfo\fP
`zipinfo` command parser
2023-01-31 17:00:42 -08:00
.TP
.B
\fB--zpool-iostat\fP
`zpool iostat` command parser
2023-02-05 09:49:32 -08:00
.TP
.B
\fB--zpool-status\fP
`zpool status` command parser
2021-07-19 12:08:50 -07:00
.RE
.PP
.B
Options:
.RS
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-a\fP, \fB--about\fP
2022-06-06 10:49:17 -07:00
About \fBjc\fP (JSON or YAML output)
2021-07-19 12:08:50 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-C\fP, \fB--force-color\fP
2023-01-27 14:47:08 -08:00
Force color output even when using pipes (overrides \fB-m\fP and the
\fBNO_COLOR\fP env variable)
2021-12-08 08:22:28 -08:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-d\fP, \fB--debug\fP
2022-06-06 10:49:17 -07:00
Debug - show traceback (use \fB-dd\fP for verbose traceback)
2021-07-19 12:08:50 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-h\fP, \fB--help\fP
2023-01-27 14:47:08 -08:00
Help (\fB--help --parser_name\fP for parser documentation). Use twice to show
2024-01-29 09:38:57 -08:00
hidden parsers (e.g. \fB-hh\fP). Use thrice to show parser categories (e.g. \fB-hhh\fP).
2021-07-19 12:08:50 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-m\fP, \fB--monochrome\fP
2022-06-06 10:49:17 -07:00
Monochrome output
2021-07-19 12:08:50 -07:00
.TP
.B
\fB-M\fP, \fB--meta-out\fP
2023-01-27 14:47:08 -08:00
Add metadata to output including timestamp, parser name, magic command, magic
command exit code, etc.
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-p\fP, \fB--pretty\fP
2022-06-06 10:49:17 -07:00
Pretty print output
2021-07-19 12:08:50 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-q\fP, \fB--quiet\fP
2024-02-12 21:31:10 -08:00
Quiet mode. Suppresses parser warning messages (use \fB-qq\fP to ignore streaming
2023-01-27 14:47:08 -08:00
parser errors)
2021-07-19 12:08:50 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-r\fP, \fB--raw\fP
2023-01-27 14:47:08 -08:00
Raw output. Provides more literal output, typically with string values and no
additional semantic processing
2021-07-19 12:08:50 -07:00
.TP
.B
2024-01-03 15:57:08 -08:00
\fB-s\fP, \fB--slurp\fP
2024-02-12 21:31:10 -08:00
Slurp multiple lines into an array. (use \fB-hhh\fP to find compatible parsers)
2024-01-03 15:57:08 -08:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-u\fP, \fB--unbuffer\fP
2022-06-06 10:49:17 -07:00
Unbuffer output (useful for slow streaming data with streaming parsers)
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-v\fP, \fB--version\fP
2022-06-06 10:49:17 -07:00
Version information
2022-05-23 13:43:57 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-y\fP, \fB--yaml-out\fP
2022-05-23 13:43:57 -07:00
YAML output
2022-06-05 17:40:05 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-B\fP, \fB--bash-comp\fP
2022-06-06 10:49:17 -07:00
Generate Bash shell completion script
2022-06-05 17:40:05 -07:00
.TP
.B
2022-06-06 10:32:18 -07:00
\fB-Z\fP, \fB--zsh-comp\fP
2022-06-06 10:49:17 -07:00
Generate Zsh shell completion script
2021-07-19 12:08:50 -07:00
2023-01-27 11:31:16 -08:00
.RE
.PP
.B
Slice:
.RS
Line slicing is supported using the \fBSTART:STOP\fP syntax similar to Python
slicing. This allows you to skip lines at the beginning and/or end of the
\fBSTDIN\fP input you would like \fBjc\fP to convert.
2023-01-27 14:47:08 -08:00
\fBSTART\fP and \fBSTOP\fP can be positive or negative integers or blank and
allow you to specify how many lines to skip and how many lines to process.
2023-01-27 11:31:16 -08:00
Positive and blank slices are the most memory efficient. Any negative
integers in the slice will use more memory.
For example, to skip the first and last line of the following text, you
could express the slice in a couple ways:
.RS
.nf
$ cat table.txt
### We want to skip this header ###
col1 col2
foo 1
bar 2
### We want to skip this footer ###
$ cat table.txt | jc 1:-1 --asciitable
[{"col1":"foo","col2":"1"},{"col1":"bar","col2":"2"}]
$ cat table.txt | jc 1:4 --asciitable
[{"col1":"foo","col2":"1"},{"col1":"bar","col2":"2"}]
.fi
.RE
In this example \fB1:-1\fP and \fB1:4\fP line slices provide the same output.
When using positive integers the index location of \fBSTOP\fP is non-inclusive.
Positive slices count from the first line of the input toward the end
starting at \fB0\fP as the first line. Negative slices count from the last line
toward the beginning starting at \fB-1\fP as the last line. This is also the way
Python's slicing feature works.
Here is a breakdown of line slice options:
.TP
.B
\fBSTART:STOP\fP
lines \fBSTART\fP through \fBSTOP - 1\fP
.TP
.B
\fBSTART:\fP
lines \fBSTART\fP through the rest of the output
.TP
.B
\fB:STOP\fP
lines from the beginning through \fBSTOP - 1\fP
.TP
.B
\fB-START:STOP\fP
\fBSTART\fP lines from the end through \fBSTOP - 1\fP
.TP
.B
\fBSTART:-STOP\fP
lines \fBSTART\fP through \fBSTOP\fP lines from the end
.TP
.B
\fB-START:-STOP\fP
\fBSTART\fP lines from the end through \fBSTOP\fP lines from the end
.TP
.B
\fB-START:\fP
\fBSTART\fP lines from the end through the rest of the output
.TP
.B
\fB:-STOP\fP
lines from the beginning through \fBSTOP\fP lines from the end
.TP
.B
\fB:\fP
all lines
2024-01-26 12:25:26 -08:00
.SH SlURP
Some parsers support multi-item input and can output an array of results in a
single pass. Slurping works for string parsers that accept a single line of
input. (e.g. \fBurl\fP and \fBip-address\fP) To see a list of parsers that support
the \fB--slurp\fP option, use \fBjc -hhh\fP.
For example, you can send a file with multiple IP addresses (one per line) to
\fBjc\fP with the \fB--slurp\fP option and an array of results will output:
.RS
.nf
$ cat ip-addresses.txt | jc --slurp --ip-address
[<multiple output objects>]
.fi
.RE
The magic syntax for \fB/proc\fP files automatically supports slurping of multiple
files (no need to use the \fB--slurp\fP option). For example, you can convert many
PID files at once:
.RS
.nf
$ jc /proc/*/status
[<multiple output objects>]
.fi
.RE
When the \fB/proc\fP magic syntax is used and multiple files are selected, an
additional \fB_file\fP field is inserted in the output so it is easier to tell what
file each output object refers to.
Finally, the \fB--meta-out\fP option can be used in conjunction with slurped output.
In this case, the slurped output is wrapped in an object with the following
structure:
.RS
.nf
{
"result": [<multiple output objects>],
"_jc_meta": {
"parser": "url",
"timestamp": 1706235558.654576,
"slice_start": null,
"slice_end": null,
"input_list": [
"http://www.google.com",
"https://www.apple.com",
"https://www.microsoft.com"
]
}
}
.fi
.RE
With \fB--meta-out\fP, \fBinput_list\fP contains a list of inputs (actual input strings
or \fB/proc\fP filenames) so you can identify which output object relates to each
input string or \fB/proc\fP filename.
2021-07-19 12:08:50 -07:00
.SH EXIT CODES
2023-01-27 14:47:08 -08:00
Any fatal errors within \fBjc\fP will generate an exit code of \fB100\fP,
otherwise the exit code will be \fB0\fP.
2023-01-27 14:47:08 -08:00
When using the "magic" syntax (e.g. \fBjc ifconfig eth0\fP), \fBjc\fP will store
the exit code of the program being parsed and add it to the \fBjc\fP exit code.
This way it is easier to determine if an error was from the parsed program or
\fBjc\fP.
2021-07-19 12:08:50 -07:00
2021-12-08 11:21:12 -08:00
Consider the following examples using \fBifconfig\fP:
2021-07-19 12:08:50 -07:00
.RS
ifconfig exit code = \fB0\fP, jc exit code = \fB0\fP, combined exit code = \fB0\fP (no errors)
ifconfig exit code = \fB1\fP, jc exit code = \fB0\fP, combined exit code = \fB1\fP (error in ifconfig)
ifconfig exit code = \fB0\fP, jc exit code = \fB100\fP, combined exit code = \fB100\fP (error in jc)
ifconfig exit code = \fB1\fP, jc exit code = \fB100\fP, combined exit code = \fB101\fP (error in both ifconfig and jc)
.RE
When using the "magic" syntax you can also retrieve the exit code of the called
2023-01-27 14:47:08 -08:00
program by using the \fB--meta-out\fP or \fB-M\fP option. This will append a
\fB_jc_meta\fP object to the output that will include the magic command
information, including the exit code.
Here is an example with \fBping\fP:
.RS
.nf
$ jc --meta-out -p ping -c2 192.168.1.252
{
"destination_ip": "192.168.1.252",
"data_bytes": 56,
"pattern": null,
"destination": "192.168.1.252",
"packets_transmitted": 2,
"packets_received": 0,
"packet_loss_percent": 100.0,
"duplicates": 0,
"responses": [
{
"type": "timeout",
"icmp_seq": 0,
"duplicate": false
}
],
"_jc_meta": {
"parser": "ping",
"timestamp": 1661357115.27949,
"magic_command": [
"ping",
"-c2",
"192.168.1.252"
],
"magic_command_exit": 2
}
}
$ echo $?
2
.fi
.RE
2021-07-19 12:08:50 -07:00
.SH ENVIRONMENT
2021-12-08 08:35:09 -08:00
\fBCustom Colors\fP
2023-01-27 14:47:08 -08:00
You can specify custom colors via the \fBJC_COLORS\fP environment variable. The
\fBJC_COLORS\fP environment variable takes four comma separated string values in
the following format:
2021-07-19 12:08:50 -07:00
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
2023-01-27 14:47:08 -08:00
Where colors are: \fBblack\fP, \fBred\fP, \fBgreen\fP, \fByellow\fP, \fBblue\fP,
\fBmagenta\fP, \fBcyan\fP, \fBgray\fP, \fBbrightblack\fP, \fBbrightred\fP,
\fBbrightgreen\fP, \fBbrightyellow\fP, \fBbrightblue\fP, \fBbrightmagenta\fP,
\fBbrightcyan\fP, \fBwhite\fP, or \fBdefault\fP
2021-07-19 12:08:50 -07:00
For example, to set to the default colors:
.RS
JC_COLORS=blue,brightblack,magenta,green
or
JC_COLORS=default,default,default,default
.RE
2021-12-08 08:35:09 -08:00
\fBDisable Color Output\fP
2023-01-27 14:47:08 -08:00
You can set the \fBNO_COLOR\fP environment variable to any value to disable
color output in \fBjc\fP. Note that using the \fB-C\fP option to force color
output will override both the \fBNO_COLOR\fP environment variable and the
\fB-m\fP option.
2021-09-20 13:04:26 -07:00
.SH STREAMING PARSERS
2023-01-27 14:47:08 -08:00
Most parsers load all of the data from \fBSTDIN\fP, parse it, then output the
entire JSON document serially. There are some streaming parsers (e.g.
\fBls-s\fP, \fBping-s\fP, etc.) that immediately start processing and outputting
the data line-by-line as JSON Lines (aka NDJSON) while it is being received from
\fBSTDIN\fP. This can significantly reduce the amount of memory required to
parse large amounts of command output (e.g. \fBls -lR /\fP) and can sometimes
process the data more quickly. Streaming parsers have slightly different
behavior than standard parsers as outlined below.
2021-09-20 13:04:26 -07:00
.RS
Note: Streaming parsers cannot be used with the "magic" syntax
.RE
\fBIgnoring Errors\fP
2023-01-27 14:47:08 -08:00
You may want to ignore parsing errors when using streaming parsers since these
may be used in long-lived processing pipelines and errors can break the pipe. To
ignore parsing errors, use the \fB-qq\fP cli option. This will add a
\fB_jc_meta\fP object to the JSON output with a \fBsuccess\fP attribute. If
\fBsuccess\fP is \fBtrue\fP, then there were no issues parsing the line. If
\fBsuccess\fP is \fBfalse\fP, then a parsing issue was found and \fBerror\fP and
\fBline\fP fields will be added to include a short error description and the
contents of the unparsable line, respectively:
2021-09-20 13:04:26 -07:00
.RS
2021-09-23 11:54:58 -07:00
Successfully parsed line with \fB-qq\fP option:
2021-09-20 13:04:26 -07:00
.RS
2022-02-24 21:21:02 -08:00
.nf
2021-09-20 13:04:26 -07:00
{
"command_data": "data",
2021-09-23 13:08:31 -07:00
"_jc_meta": {
2021-09-20 13:04:26 -07:00
"success": true
}
}
2022-03-09 14:43:56 -08:00
.fi
2021-09-20 13:04:26 -07:00
.RE
2021-09-23 11:54:58 -07:00
Unsuccessfully parsed line with \fB-qq\fP option:
2021-09-20 13:04:26 -07:00
.RS
2022-02-24 21:21:02 -08:00
.nf
2021-09-20 13:04:26 -07:00
{
2021-09-23 13:08:31 -07:00
"_jc_meta": {
2021-09-20 13:04:26 -07:00
"success": false,
2021-09-23 12:58:24 -07:00
"error": "error message",
2021-09-20 13:04:26 -07:00
"line": "original line data"
}
}
2022-02-24 21:21:02 -08:00
.fi
2021-09-20 13:04:26 -07:00
.RE
.RE
\fBUnbuffering Output\fP
2023-01-27 14:47:08 -08:00
Most operating systems will buffer output that is being piped from process to
process. The buffer is usually around 4KB. When viewing the output in the
terminal the OS buffer is not engaged so output is immediately displayed on the
screen. When piping multiple processes together, though, it may seem as if the
output is hanging when the input data is very slow (e.g. \fBping\fP):
2021-09-20 13:04:26 -07:00
.RS
2022-02-24 21:21:02 -08:00
.nf
2022-03-09 14:17:48 -08:00
$ ping 1.1.1.1 | jc \fB--ping-s\fP | jq
2021-09-20 13:04:26 -07:00
<slow output>
2022-02-24 21:21:02 -08:00
.fi
2021-09-20 13:04:26 -07:00
.RE
2023-01-27 14:47:08 -08:00
This is because the OS engages the 4KB buffer between \fBjc\fP and \fBjq\fP in
this example. To display the data on the terminal in realtime, you can disable
the buffer with the \fB-u\fP (unbuffer) cli option:
2021-09-20 13:04:26 -07:00
.RS
2022-02-24 21:21:02 -08:00
.nf
2022-03-09 14:17:48 -08:00
$ ping 1.1.1.1 | jc \fB--ping-s\fP \fB-u\fP | jq
2022-02-24 21:21:02 -08:00
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64",...}
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64",...}
2021-09-20 13:04:26 -07:00
etc...
2022-02-24 21:21:02 -08:00
.fi
2021-09-20 13:04:26 -07:00
2021-09-23 08:53:25 -07:00
Note: Unbuffered output can be slower for large data streams.
2021-09-20 13:04:26 -07:00
.RE
.SH PARSER PLUGINS
Parser plugins may be placed in a \fBjc/jcparsers\fP folder in your
2023-01-27 14:47:08 -08:00
local "App data directory":
2021-07-19 12:08:50 -07:00
.RS
2022-03-09 14:17:48 -08:00
.nf
2021-07-19 12:08:50 -07:00
- Linux/unix: \fB$HOME/.local/share/jc/jcparsers\fP
- macOS: \fB$HOME/Library/Application Support/jc/jcparsers\fP
- Windows: \fB$LOCALAPPDATA\\jc\\jc\\jcparsers\fP
2022-03-09 14:17:48 -08:00
.fi
2021-07-19 12:08:50 -07:00
.RE
Parser plugins are standard python module files. Use the
2023-01-27 14:47:08 -08:00
\fBjc/parsers/foo.py\fP or \fBjc/parsers/foo_s.py\fP (streaming) parser as a
template and simply place a \fB.py\fP file in the \fBjcparsers\fP subfolder.
Any dependencies can be placed in the \fBjc\fP folder above \fBjcparsers\fP
and can be imported in the parser code.
2021-07-19 12:08:50 -07:00
Parser plugin filenames must be valid python module names and therefore must
2023-01-27 14:47:08 -08:00
start with a letter and consist entirely of alphanumerics and underscores. Local
plugins may override default parsers.
2021-07-19 12:08:50 -07:00
2023-01-27 14:47:08 -08:00
Note: The application data directory follows the \fBXDG Base Directory
Specification\fP
2021-07-19 12:08:50 -07:00
.SH CAVEATS
2022-05-12 11:16:44 -07:00
\fBLocale\fP
2022-07-30 12:23:43 -07:00
For best results set the locale environment variables to \fBC\fP or
\fBen_US.UTF-8\fP by modifying the \fBLC_ALL\fP variable:
2021-07-19 12:08:50 -07:00
2022-03-09 14:17:48 -08:00
.RS
2022-07-30 12:23:43 -07:00
$ LC_ALL=C date | jc \fB--date\fP
2022-03-09 14:17:48 -08:00
.RE
2021-07-19 12:08:50 -07:00
2022-07-30 12:23:43 -07:00
You can also set the locale variables individually:
2021-07-19 12:08:50 -07:00
2022-03-09 14:17:48 -08:00
.RS
$ export LANG=C
2022-07-30 12:23:43 -07:00
$ export LC_NUMERIC=C
2022-03-09 14:17:48 -08:00
.RE
2021-07-19 12:08:50 -07:00
2022-07-30 12:23:43 -07:00
On some older systems UTF-8 output will be downgraded to ASCII with \fB\\u\fP
escape sequences if the \fBC\fP locale does not support UTF-8 encoding.
2022-05-12 11:16:44 -07:00
\fBTimezones\fP
2022-04-26 17:51:30 -07:00
2023-01-27 14:47:08 -08:00
Some parsers have calculated epoch timestamp fields added to the output. Unless
a timestamp field name has a \fB_utc\fP suffix it is considered naive. (i.e.
based on the local timezone of the system the \fBjc\fP parser was run on).
2021-07-19 12:08:50 -07:00
2023-01-27 14:47:08 -08:00
If a UTC timezone can be detected in the text of the command output, the
timestamp will be timezone aware and have a \fB_utc\fP suffix on the key name.
(e.g. \fBepoch_utc\fP) No other timezones are supported for aware timestamps.
2021-07-19 12:08:50 -07:00
.SH EXAMPLES
Standard Syntax:
.RS
2022-09-07 13:56:16 -07:00
$ dig www.google.com | jc \fB-p\fP \fB--dig\fP
$ cat /proc/meminfo | jc \fB--pretty\fP \fB--proc\fP
2021-07-19 12:08:50 -07:00
.RE
Magic Syntax:
.RS
2022-09-07 13:56:16 -07:00
$ jc \fB--pretty\fP dig www.google.com
$ jc \fB--pretty\fP /proc/meminfo
2021-07-19 12:08:50 -07:00
.RE
2023-02-05 09:49:32 -08:00
Line Slicing:
.RS
$ cat file.csv | jc \fB:101\fP \fB--csv\fP # parse first 100 lines
.RE
2021-07-19 12:08:50 -07:00
For parser documentation:
.RS
2022-09-07 13:56:16 -07:00
$ jc \fB--help\fP \fB--dig\fP
2021-07-19 12:08:50 -07:00
.RE
2023-02-05 09:49:32 -08:00
More Help:
.RS
$ jc \fB-hh\fP # show hidden parsers
$ jc \fB-hhh\fP # list parsers by category tags
.RE
2021-07-19 12:08:50 -07:00
.SH AUTHOR
Kelly Brazil (kellyjonbrazil@gmail.com)
https://github.com/kellyjonbrazil/jc
.SH COPYRIGHT
2024-01-03 15:57:08 -08:00
Copyright (c) 2019-2024 Kelly Brazil
2021-07-19 12:08:50 -07:00
License: MIT License