From 6f00b6fd61ca0e1247cab45cc4b2ebababf27b89 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sat, 23 Jul 2022 10:57:46 -0700 Subject: [PATCH] doc update --- EXAMPLES.md | 189 ++++++++++++++++++++++++++++++++++++-------- docs/parsers/url.md | 2 +- jc/parsers/url.py | 2 +- 3 files changed, 156 insertions(+), 37 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index c326e6a0..1edd73ce 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -922,6 +922,18 @@ du /usr | jc --du -p # or: jc -p du /usr } ] ``` +### Email Address string +```bash +echo 'joe.user@gmail.com' | jc --email-address -p +``` +```json +{ + "username": "joe.user", + "domain": "gmail.com", + "local": "joe.user", + "local_plus_suffix": null +} +``` ### env ```bash env | jc --env -p # or: jc -p env @@ -1715,6 +1727,31 @@ iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p ip } ] ``` +### ISO Datetime string +```bash +echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p +``` +```json +{ + "year": 2022, + "month": "Jul", + "month_num": 7, + "day": 20, + "weekday": "Wed", + "weekday_num": 3, + "hour": 2, + "hour_24": 14, + "minute": 52, + "second": 45, + "microsecond": 0, + "period": "PM", + "utc_offset": "+0000", + "day_of_year": 201, + "week_of_year": 29, + "iso": "2022-07-20T14:52:45+00:00", + "timestamp": 1658328765 +} +``` ### iw dev `device` scan ```bash iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan @@ -1861,6 +1898,24 @@ jobs -l | jc --jobs -p } ] ``` +### JWT string +```bash +echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p +``` +```json +{ + "header": { + "alg": "HS256", + "typ": "JWT" + }, + "payload": { + "sub": "1234567890", + "name": "John Doe", + "iat": 1516239022 + }, + "signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..." +} +``` ### Key/Value files ```bash cat keyvalue.txt @@ -2197,7 +2252,7 @@ lsusb -v | jc --lsusb -p # or: jc -p lsusb -v } ] ``` -### M3U and M3U8 +### M3U and M3U8 files ```bash cat playlist.m3u | jc --m3u -p ``` @@ -2527,40 +2582,40 @@ nmcli connection show ens33 | jc --nmcli -p # or jc -p nmcli connection ``` ```json [ - { - "connection_id": "ens33", - "connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744", - "connection_stable_id": null, - "connection_type": "802-3-ethernet", - "connection_interface_name": "ens33", - "connection_autoconnect": "yes", - "ip4_address_1": "192.168.71.180/24", - "ip4_gateway": "192.168.71.2", - "ip4_route_1": { - "dst": "0.0.0.0/0", - "nh": "192.168.71.2", - "mt": 100 - }, - "ip4_route_2": { - "dst": "192.168.71.0/24", - "nh": "0.0.0.0", - "mt": 100 - }, - "ip4_dns_1": "192.168.71.2", - "ip4_domain_1": "localdomain", - "dhcp4_option_1": { - "name": "broadcast_address", - "value": "192.168.71.255" - }, - "ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64", - "ip6_gateway": null, - "ip6_route_1": { - "dst": "fe80::/64", - "nh": "::", - "mt": 100 - } - } - ] + { + "connection_id": "ens33", + "connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744", + "connection_stable_id": null, + "connection_type": "802-3-ethernet", + "connection_interface_name": "ens33", + "connection_autoconnect": "yes", + "ip4_address_1": "192.168.71.180/24", + "ip4_gateway": "192.168.71.2", + "ip4_route_1": { + "dst": "0.0.0.0/0", + "nh": "192.168.71.2", + "mt": 100 + }, + "ip4_route_2": { + "dst": "192.168.71.0/24", + "nh": "0.0.0.0", + "mt": 100 + }, + "ip4_dns_1": "192.168.71.2", + "ip4_domain_1": "localdomain", + "dhcp4_option_1": { + "name": "broadcast_address", + "value": "192.168.71.255" + }, + "ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64", + "ip6_gateway": null, + "ip6_route_1": { + "dst": "fe80::/64", + "nh": "::", + "mt": 100 + } + } +] ``` ### ntpq ```bash @@ -4032,6 +4087,70 @@ uptime | jc --uptime -p # or: jc -p uptime "uptime_total_seconds": 273780 } ``` +### URL string +```bash +echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ + | jc --url -p +``` +```json +{ + "url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag", + "scheme": "http", + "netloc": "example.com", + "path": "/test/path", + "path_list": [ + "test", + "path" + ], + "query": "q1=foo&q1=bar&q2=baz", + "query_obj": { + "q1": [ + "foo", + "bar" + ], + "q2": [ + "baz" + ] + }, + "fragment": "frag", + "username": null, + "password": null, + "hostname": "example.com", + "port": null, + "encoded": { + "url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag", + "scheme": "http", + "netloc": "example.com", + "path": "/test/path", + "path_list": [ + "test", + "path" + ], + "query": "q1=foo&q1=bar&q2=baz", + "fragment": "frag", + "username": null, + "password": null, + "hostname": "example.com", + "port": null + }, + "decoded": { + "url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag", + "scheme": "http", + "netloc": "example.com", + "path": "/test/path", + "path_list": [ + "test", + "path" + ], + "query": "q1=foo&q1=bar&q2=baz", + "fragment": "frag", + "username": null, + "password": null, + "hostname": "example.com", + "port": null + } +} +``` ### w ```bash w | jc --w -p # or: jc -p w diff --git a/docs/parsers/url.md b/docs/parsers/url.md index ac464631..11e0ee04 100644 --- a/docs/parsers/url.md +++ b/docs/parsers/url.md @@ -89,7 +89,7 @@ Schema: Examples: - % echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ + $ echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ | jc --url -p { "url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag", diff --git a/jc/parsers/url.py b/jc/parsers/url.py index 8789f839..3eea76e9 100644 --- a/jc/parsers/url.py +++ b/jc/parsers/url.py @@ -84,7 +84,7 @@ Schema: Examples: - % echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ + $ echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ | jc --url -p { "url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",