From cb3484e1ab564598bee10397b95d85e339c31eaf Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 4 Aug 2022 15:43:44 -0700 Subject: [PATCH] doc update --- EXAMPLES.md | 84 +++++++++++++++++++++++++++++++++++++++++++ docs/parsers/plist.md | 35 +++++++++++------- jc/parsers/plist.py | 37 +++++++++++-------- 3 files changed, 129 insertions(+), 27 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 2bf236ab..b7e1a096 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -1665,6 +1665,65 @@ $ iostat | jc --iostat -p # or: jc -p iostat } ] ``` +### IP Address strings +```bash +echo 192.168.2.10/24 | jc --ip-address -p +``` +```json +{ + "version": 4, + "max_prefix_length": 32, + "ip": "192.168.2.10", + "ip_compressed": "192.168.2.10", + "ip_exploded": "192.168.2.10", + "scope_id": null, + "ipv4_mapped": null, + "six_to_four": null, + "teredo_client": null, + "teredo_server": null, + "dns_ptr": "10.2.168.192.in-addr.arpa", + "network": "192.168.2.0", + "broadcast": "192.168.2.255", + "hostmask": "0.0.0.255", + "netmask": "255.255.255.0", + "cidr_netmask": 24, + "hosts": 254, + "first_host": "192.168.2.1", + "last_host": "192.168.2.254", + "is_multicast": false, + "is_private": true, + "is_global": false, + "is_link_local": false, + "is_loopback": false, + "is_reserved": false, + "is_unspecified": false, + "int": { + "ip": 3232236042, + "network": 3232236032, + "broadcast": 3232236287, + "first_host": 3232236033, + "last_host": 3232236286 + }, + "hex": { + "ip": "c0:a8:02:0a", + "network": "c0:a8:02:00", + "broadcast": "c0:a8:02:ff", + "hostmask": "00:00:00:ff", + "netmask": "ff:ff:ff:00", + "first_host": "c0:a8:02:01", + "last_host": "c0:a8:02:fe" + }, + "bin": { + "ip": "11000000101010000000001000001010", + "network": "11000000101010000000001000000000", + "broadcast": "11000000101010000000001011111111", + "hostmask": "00000000000000000000000011111111", + "netmask": "11111111111111111111111100000000", + "first_host": "11000000101010000000001000000001", + "last_host": "11000000101010000000001011111110" + } +} +``` ### iptables ```bash iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p iptables --line-numbers -v -L -t nat @@ -2832,6 +2891,31 @@ pip show wrapt wheel | jc --pip-show -p # or: jc -p pip show wrapt whe } ] ``` +### PLIST files +```bash +cat info.plist | jc --plist -p +``` +```json +{ + "NSAppleScriptEnabled": true, + "LSMultipleInstancesProhibited": true, + "CFBundleInfoDictionaryVersion": "6.0", + "DTPlatformVersion": "GM", + "CFBundleIconFile": "GarageBand.icns", + "CFBundleName": "GarageBand", + "DTSDKName": "macosx10.13internal", + "NSSupportsAutomaticGraphicsSwitching": true, + "RevisionDate": "2018-12-03_14:10:56", + "UTImportedTypeDeclarations": [ + { + "UTTypeConformsTo": [ + "public.data", + "public.content" + ] + } + ] +} +``` ### postconf -M ```bash postconf -M | jc --postconf -p # or jc -p postconf -M diff --git a/docs/parsers/plist.md b/docs/parsers/plist.md index 3e77c28c..14b34c78 100644 --- a/docs/parsers/plist.md +++ b/docs/parsers/plist.md @@ -20,25 +20,34 @@ Usage (cli): Usage (module): import jc - result = jc.parse('plist', plist_command_output) + result = jc.parse('plist', plist_file_output) Schema: - [ - { - "plist": string, - "bar": boolean, - "baz": integer - } - ] + { + "": string/integer/float/boolean/object/array/null + } Examples: - $ plist | jc --plist -p - [] - - $ plist | jc --plist -p -r - [] + $ cat info.plist | jc --plist -p + { + "NSAppleScriptEnabled": true, + "LSMultipleInstancesProhibited": true, + "CFBundleInfoDictionaryVersion": "6.0", + "DTPlatformVersion": "GM", + "CFBundleIconFile": "GarageBand.icns", + "CFBundleName": "GarageBand", + "DTSDKName": "macosx10.13internal", + "NSSupportsAutomaticGraphicsSwitching": true, + "RevisionDate": "2018-12-03_14:10:56", + "UTImportedTypeDeclarations": [ + { + "UTTypeConformsTo": [ + "public.data", + "public.content" + ... + } diff --git a/jc/parsers/plist.py b/jc/parsers/plist.py index 0dbbab52..8cce3837 100644 --- a/jc/parsers/plist.py +++ b/jc/parsers/plist.py @@ -15,27 +15,36 @@ Usage (cli): Usage (module): import jc - result = jc.parse('plist', plist_command_output) + result = jc.parse('plist', plist_file_output) Schema: - [ - { - "plist": string, - "bar": boolean, - "baz": integer - } - ] + { + "": string/integer/float/boolean/object/array/null + } Examples: - $ plist | jc --plist -p - [] - - $ plist | jc --plist -p -r - [] + $ cat info.plist | jc --plist -p + { + "NSAppleScriptEnabled": true, + "LSMultipleInstancesProhibited": true, + "CFBundleInfoDictionaryVersion": "6.0", + "DTPlatformVersion": "GM", + "CFBundleIconFile": "GarageBand.icns", + "CFBundleName": "GarageBand", + "DTSDKName": "macosx10.13internal", + "NSSupportsAutomaticGraphicsSwitching": true, + "RevisionDate": "2018-12-03_14:10:56", + "UTImportedTypeDeclarations": [ + { + "UTTypeConformsTo": [ + "public.data", + "public.content" + ... + } """ -from typing import List, Dict, Union +from typing import Dict, Union import plistlib import binascii from datetime import datetime