1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-03 17:44:07 +02:00

Compare commits

...

247 Commits

Author SHA1 Message Date
Kelly Brazil
2cdbebb7fd Merge pull request #542 from kellyjonbrazil/dev
Dev v1.25.1
2024-02-13 00:35:00 +00:00
Kelly Brazil
412f11276a fix sys.path update 2024-02-12 16:18:52 -08:00
Kelly Brazil
f3dd51f517 hard-code disabled parser path 2024-02-12 15:53:21 -08:00
Kelly Brazil
f66f1aadaa use shlex to correctly split the /proc files in magic_run_command_str 2024-02-12 15:32:38 -08:00
Kelly Brazil
8ead7e4835 rename List class to _List for documentation purposes 2024-02-12 15:05:44 -08:00
Kelly Brazil
f1177a2606 add more coverage for --quiet cli option 2024-02-12 11:00:27 -08:00
Kelly Brazil
44dc2a74c1 add test for jc -h 2024-02-12 11:00:02 -08:00
Kevin Lyter
d50bd96ce6 [xrandr] Allow props command (#540)
* [xrandr] Allow props command

Responding to issue #525
Somewhat substantial rewriting here to make the parser more resilient
- Change parser to not mutate the incoming data list, instead index
- Create `Line` class and `categorize` classmethod
  - Every line is categorized and regexed, so it gets dispatched to the
  right level of responsibility

* Bump version

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-12 09:03:25 -08:00
Kelly Brazil
5cde127a04 raise ParseError instead of output empty object for disabled parser 2024-02-10 14:58:15 -08:00
Kelly Brazil
63d1cead90 enhance uptime parser for busybox output with no user info 2024-02-10 11:55:19 -08:00
Kelly Brazil
d3e7f09ca3 fix for more graceful handling of missing optional libraries 2024-02-10 11:16:38 -08:00
Kelly Brazil
e6bdbb42d3 add more ini tests 2024-02-09 19:32:19 -08:00
Kelly Brazil
3cfc5e3e3c fix ini parser for edge cases with non-value keys 2024-02-09 17:13:19 -08:00
Kelly Brazil
082d4a3f80 doc update 2024-02-07 11:53:13 -08:00
Kelly Brazil
158c28455b version bump 2024-02-05 18:30:26 -08:00
Kelly Brazil
efb02493b8 remove extra $ from slicing example 2024-02-05 18:22:05 -08:00
Kelly Brazil
a319ec85ca doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
e754e88f2d doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
cfa7f267fc update schema 2024-02-06 01:54:31 +00:00
Kelly Brazil
c581e959fa formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
9eb56543be add verbosity check for printing 2024-02-06 01:54:31 +00:00
Kelly Brazil
67643906b1 formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
14d257225c doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
0411940f75 add full path to error messages 2024-02-06 01:54:31 +00:00
Kelly Brazil
7d60df67f3 check for missing fixtures 2024-02-06 01:54:31 +00:00
Kelly Brazil
70a971a2f1 formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
3fbdffd028 efibootmgr updates 2024-02-06 01:54:31 +00:00
yaofei zheng
539fe72d16 add "sudo efibootmgr" (without -v) output test case (#534) 2024-02-06 01:54:31 +00:00
Kelly Brazil
bd6611aaba doc updates 2024-02-06 01:54:31 +00:00
Kelly Brazil
cf77ddc396 cleanup 2024-02-06 01:54:31 +00:00
Kelly Brazil
77bcd616cd add tests for curl-head and http-headers parsers 2024-02-06 01:54:31 +00:00
yaofei zheng
5ee2eda83e add efibootmgr parser (#528)
* More nsd fixes (#523)

* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata

* Revert "More nsd fixes" (#526)

* add efibootmgr parser

* add efibootmgr completions

* Multiple fixes on jc/parsers/efibootmgr.py

1. Update schema in comments.
1. Add an example.
1. Use clean and clear sub string finding sytax.
1. Wrap schema in an object.
1. Make variable scope as small as possible.

* add tests for efibootmgr

* Update jc/parsers/efibootmgr.py

Update example using `--pretty` for output.

Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>

* jc/parsers/efibootmgr multiple changes

1. convert all keys to "snake_case"
2. add "mirrored_percentage_above_4g" and "mirror_memory_below_4gb"
3. move conversion (from string to other types) to "_process"

---------

Co-authored-by: pettai <pettai@sunet.se>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
5b849b0275 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
3e5d206f0c test utils cleanup 2024-02-06 01:54:31 +00:00
Kelly Brazil
f50f96381d doc update 2024-02-06 01:54:31 +00:00
Muescha
962632ac1f Feature: generic fixtures tests (#529)
* add generic test runners

* extract generic test runners

* beautify messages, remove unused return value

* add template and info do CONTRIBUTING

* typo

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
d209780a9d only add timestamp field if datetime string is parsable 2024-02-06 01:54:31 +00:00
Kelly Brazil
8e5451a7c1 fix for datetime or integer fields 2024-02-06 01:54:31 +00:00
Kelly Brazil
86a09c17cf remove unused _process function 2024-02-06 01:54:31 +00:00
Kelly Brazil
4bb85195e2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
39f43aad63 add http_headers and curl_head parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
29689f7603 formatting 2024-02-06 01:54:31 +00:00
Muescha
78d7ab1308 add info about documentation and completions (#531) 2024-02-06 01:54:31 +00:00
Kelly Brazil
303cd12de3 version bump to v1.25.0 2024-02-06 01:54:31 +00:00
Kelly Brazil
b65f37e075 add normalize_key() function and tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
c05fa7e9cd add remove_quotes() to utils and use in ini parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
264272a8b8 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
7fadb23fea use convert_size_to_int() 2024-02-06 01:54:31 +00:00
Kelly Brazil
c419e460db doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
6434ff61bf add HTTP header datetime format 2024-02-06 01:54:31 +00:00
Kelly Brazil
45a1be11e2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
7659fe470a formatting 2024-02-06 01:54:31 +00:00
Muescha
c332c4febf draft for path and path_list (#513)
* draft for path_list

* updaate doc

* add input check

* fix types

* fix schema: add missing properties

* add _process

* fix _process docs

* refactor: extract path.py parser

* swap order of names alphabetically

* documentation and comments

* path parser: add early return for nodata

* path and path-list parser: add test and fixtures

* typo in file name

* add early return for nodata

* add test and fixtures

* typo in file name

* rename fixtures

* rename fixtures

* refactor to pathlib.Path

* failing on windows - use PurePosixPath

* changed the way to strip dot from suffix

* add POSIX to path

* test commit to see results on windows is failing

* test commit to see results on windows is failing

* add windows path detection

* somehow Path not like the newline from input line

* add test with more items

* remove debug print

* wrap test loops into into subTest

* remove print statements

* add path and path-list to CHANGELOG

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
2cc212bfab use convert_size_to_int() from utils 2024-02-06 01:54:31 +00:00
Kelly Brazil
b836ffc583 add tests for convert_size_to_int() 2024-02-06 01:54:31 +00:00
Kelly Brazil
29f1a1d425 fix proc doc - output is dict or list of dicts 2024-02-06 01:54:31 +00:00
Kelly Brazil
9f78dc6afa proc parser doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
74c7e11948 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
6ba6dc0374 version bump 2024-02-06 01:54:31 +00:00
pettai
ec0f2569e5 More nsd fixes (#523)
* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata
2024-02-06 01:54:31 +00:00
Kelly Brazil
65e30c4440 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
8d9ebf5dfa doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c3746454ff doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
ea0f6493a2 update contributing guide 2024-02-06 01:54:31 +00:00
Kelly Brazil
afbc46076e add ping tests 2024-02-06 01:54:31 +00:00
Mabuchin
2b9b6550a7 Fix data_bytes is null in ping -I option (#520)
* fixed header parsing when specifying ping interface

* add source_ip parsing test for ping/ping-s

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
6fb3c0a409 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
1b8911ad36 add slurp docs 2024-02-06 01:54:31 +00:00
Kelly Brazil
cc61b57dd1 add blank line tests to slicer 2024-02-06 01:54:31 +00:00
Kelly Brazil
6d679b2895 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
1e1fc08a47 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
b5c3a03d56 implement slurp by wrapping in a list, adding "_file" for /proc, and further wrapping in {"result": data} when --meta-out is used. 2024-02-06 01:54:31 +00:00
Kelly Brazil
9e269f070f update slice help doc 2024-02-06 01:54:31 +00:00
Kelly Brazil
f863cfdef4 fix for slicing blank lines 2024-02-06 01:54:31 +00:00
Kelly Brazil
2cd58d75e7 make parser_shortname more robust 2024-02-06 01:54:31 +00:00
Kelly Brazil
03b70eebb7 make /proc slurpable with magic syntax 2024-02-06 01:54:31 +00:00
Kelly Brazil
1e76ce2aea doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
d9fc1b4242 doc update 2024-02-06 01:54:31 +00:00
Muescha
36a3d2e96d crontab remove double entry in doc (#518) 2024-02-06 01:54:31 +00:00
Kelly Brazil
bf05de1d63 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
cae41df1d8 add get_parser tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
8e9ff7fa9f refactor to use get_parser() 2024-02-06 01:54:31 +00:00
Muescha
973c535c72 extract to public jc.get_parser(parser_name) (#516)
* remove unused imports and RegEx

* extract to public jc.get_parser(parser_name)

* changed order of exports

* add doc

* add doc.md

* remove data_dir from doc.md

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Muescha
8614d3dde9 remove unused imports and RegEx (#515) 2024-02-06 01:54:31 +00:00
Kelly Brazil
a73ee47bcf move slurp error message so it will work for all parser types 2024-02-06 01:54:31 +00:00
Kelly Brazil
d54a81831f update slicer to use utils.line_slice() 2024-02-06 01:54:31 +00:00
Kelly Brazil
73ae1396b9 enhance slurp error message 2024-02-06 01:54:31 +00:00
Kelly Brazil
3399e8551e add slurpable_parser_mod_list test 2024-02-06 01:54:31 +00:00
Kelly Brazil
b9656c2fae add line_slice tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
e08ccb7942 add slurp test. fix cli_json_out_pretty test 2024-02-06 01:54:31 +00:00
Kelly Brazil
9b648e8560 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c97a8fb48f add line_slice function 2024-02-06 01:54:31 +00:00
Kelly Brazil
3a95407161 back out slurp array flattening code 2024-02-06 01:54:31 +00:00
Kelly Brazil
7609af28b3 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c2b2e81a2b add more slurpable parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
3b0594a4a6 flatten slurp output if parser outputs a list 2024-02-06 01:54:31 +00:00
Kelly Brazil
2b0b9dd7ba doc update 2024-02-06 01:54:31 +00:00
don Rumata
f159dd6b9d Add plugins support 4 snapcraft (#512)
* Added `snap` support.

* Added plugins support.

* Add README 4 snap.

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
2d5d87c73d version bump and doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
a260ceba1c add slurp functionality 2024-02-06 01:54:31 +00:00
Kelly Brazil
6c30b8106c use PurePosixPath to fix tests running on Windows 2024-02-06 01:54:31 +00:00
Kelly Brazil
a23921c879 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
3999276d17 add parent, filename, stem, and extension to schema 2024-02-06 01:54:31 +00:00
Kelly Brazil
65bd4850f2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
d71c2d2b20 add kv_dup tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
6dd5b29998 fix to make None values always a blank string 2024-02-06 01:54:31 +00:00
Kelly Brazil
1868b28f74 doc fix 2024-02-06 01:54:31 +00:00
Kelly Brazil
e8c0bef6ca doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
2c09a06b5a add kv_dup parser 2024-02-06 01:54:31 +00:00
Kelly Brazil
fc75ce90d1 refactor alias parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
45a6cfc9cf add source info to docs 2024-02-06 01:54:31 +00:00
Kelly Brazil
69a0922410 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
2bb201a706 fix parser source path 2024-02-06 01:54:31 +00:00
Kelly Brazil
50d5d3a3ba add opposite endian ipv6 addresses for s390x and other Big Endian architecture support 2024-02-06 01:54:31 +00:00
Kelly Brazil
b14a8980b8 add more info for unit tests 2024-02-06 01:54:31 +00:00
muescha
de6aa1cc92 change \n to echo to create new lines 2024-02-06 01:54:31 +00:00
Muescha
c4dcedb269 Update docgen.sh: add link to source 2024-02-06 01:54:31 +00:00
Kelly Brazil
140a61702b Revert "More nsd fixes" (#526) 2024-01-26 14:22:13 -08:00
pettai
4d3fc07e3b More nsd fixes (#523)
* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata
2024-01-26 14:20:33 -08:00
Kelly Brazil
dcc4d35d55 Merge branch 'dev' into master 2023-12-21 22:02:56 +00:00
Muescha
cfb30b32f3 Update CONTRIBUTING.md (#509)
* Update CONTRIBUTING.md

fix:
- bullet points
- fix link to custom plugins
- add info about appending to `jc/lib.py`

* Update CONTRIBUTING.md

fix numbering

* typo: lowercase
2023-12-21 07:42:04 -08:00
Kelly Brazil
26f2738471 Merge pull request #502 from kellyjonbrazil/master
sync to dev
2023-12-18 20:13:45 +00:00
Kelly Brazil
2bccd14c5d Merge pull request #499 from kellyjonbrazil/dev
v1.24.0
2023-12-17 18:08:02 +00:00
Kelly Brazil
0d4823c9de doc update 2023-12-17 09:44:18 -08:00
Kelly Brazil
2a14f56b72 add proc-cmdline tests 2023-12-16 13:18:14 -08:00
Kelly Brazil
fe49759598 doc update 2023-12-16 12:59:35 -08:00
Kelly Brazil
ee737a59eb doc update 2023-12-16 12:55:29 -08:00
Kelly Brazil
517ab10930 add proc-cmdline parser 2023-12-16 12:09:37 -08:00
Kelly Brazil
604fb574be doc update 2023-12-16 11:44:11 -08:00
Kelly Brazil
a254ee8d88 add test for issue 490 2023-12-16 11:39:40 -08:00
Kelly Brazil
f784a7a76d doc update 2023-12-10 13:13:57 -08:00
Kelly Brazil
2e33afbe18 doc cleanup 2023-12-10 10:53:28 -08:00
Kelly Brazil
103bb174fc rename pkg-index-alpine to pkg-index-apk 2023-12-10 10:49:05 -08:00
Kelly Brazil
2a76a64fa1 schema update 2023-12-10 10:41:20 -08:00
Kelly Brazil
c8fb56c601 formatting 2023-12-10 10:41:09 -08:00
Kelly Brazil
e835227027 doc update 2023-12-10 10:30:05 -08:00
Kelly Brazil
88ffcaee56 update schema. fix no-data output to match other parsers. 2023-12-10 10:29:58 -08:00
Kelly Brazil
a9ba98847c update _device_pattern regex for Freezing with 100% CPU when parsing Xrandr output - 1.23.6 #490 2023-12-09 17:01:03 -08:00
Kelly Brazil
2630049ab7 possible fix for infinite loop issue 2023-12-09 16:14:27 -08:00
Kelly Brazil
47c7e081f3 doc update 2023-12-09 11:45:26 -08:00
Kelly Brazil
ef7f755614 doc update 2023-12-09 11:41:45 -08:00
Kelly Brazil
32bd7ffbf6 formatting updates 2023-12-09 11:41:22 -08:00
Kelly Brazil
347097a294 add convert_size_to_int function 2023-12-09 11:41:06 -08:00
Kelly Brazil
356857f5d6 rename deb-packages-index to pkg-index-deb 2023-12-09 10:17:48 -08:00
Kelly Brazil
ee12c52291 rename apkindex parser to pkg-index-alpine 2023-12-09 10:03:33 -08:00
Ron Green
0e7ebf4dc1 feat(iftop): add iftop-scanning (#484)
* feat(iftop): add iftop-scanning

this is not even an MVP, but I would like it to exist to allow per client json aggregation

also, a future use is a stream response

* fix typos and test first regex

* add more iftop fun

* Update iftop.py

* add tests and json

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* feat: make work and add tests

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* add completion

* change schema for query looping

* fix: tests

* fix review comments

* feat: add byte parsing

* add no-port to options

* remove completion and format dep

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* Update setup.py

* Update iftop.py

---------

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-07 18:22:53 -08:00
Kelly Brazil
f1e0cec9d6 add apkindex parser 2023-12-04 14:01:30 -08:00
Roey Darwish Dror
d96a2a8623 APKINDEX parser (#487) (#491)
* APKINDEX parser (#487)

* Missing space in doc
2023-12-04 13:35:04 -08:00
Hugo van Kemenade
1b1bc46222 Remove redundant Python 2 code (#493)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-04 13:03:15 -08:00
Kelly Brazil
d5a8b4eed2 remove deprecated iso-datetime parser 2023-12-04 11:35:37 -08:00
Kelly Brazil
5ddd4f0e86 version bump to 1.24.0 2023-12-04 11:33:04 -08:00
Kelly Brazil
8b94c326de add no data test 2023-12-04 09:59:28 -08:00
Hugo van Kemenade
29b012e66d Add support for Python 3.12 (#492)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-04 09:55:07 -08:00
Kelly Brazil
572a3207cd doc update 2023-11-28 11:23:47 -08:00
Kelly Brazil
2a88f2be6b fix mypy issues 2023-11-28 11:21:13 -08:00
Roey Darwish Dror
3de6eac1ad swapon parser (#383) (#489)
* swapon parser

* revert lib

* fix lib

* Added tests

* Fix tests

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-11-28 11:15:40 -08:00
Kelly Brazil
f44260603e doc update 2023-11-24 10:38:33 -08:00
Kelly Brazil
1c60f5355e convert one more field to integer 2023-11-24 09:45:56 -08:00
Kelly Brazil
40fa78a966 version bump 2023-11-24 09:44:03 -08:00
Himadri Bhattacharjee
71db67ef49 refactor: acpi parser: adhere code to the happy path to avoid nested branches (#488)
* refactor: acpi parser: keep working code in happy path to avoid nested branches

* fix: use elif for branches marked charging and discharging

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-11-24 09:38:10 -08:00
Kelly Brazil
1cd723b48f add tests 2023-11-23 15:19:14 -08:00
Kelly Brazil
82ee4d7b30 add debconf-show parser 2023-11-23 14:52:06 -08:00
Kelly Brazil
dfd19f38f3 doc update 2023-11-23 12:12:05 -08:00
Kelly Brazil
2358c883d0 remove unused type annotation import 2023-11-23 12:07:54 -08:00
Kelly Brazil
79e4f3a761 doc update 2023-11-23 12:05:03 -08:00
Kelly Brazil
5be45622cc Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2023-11-23 12:01:54 -08:00
Kelly Brazil
5f4136b943 run tests 2023-11-23 12:00:58 -08:00
Kelly Brazil
941bfe2724 update szenius/set-timezone to v1.2 2023-11-23 11:59:12 -08:00
Kelly Brazil
3ed44a26d9 doc update 2023-11-23 11:51:04 -08:00
Kelly Brazil
b7270517bd add tune2fs parser 2023-11-23 11:49:04 -08:00
Kelly Brazil
bf63ac93c6 add Photon linux 2023-11-21 15:01:04 -08:00
Kelly Brazil
1cb80f15c2 add tests 2023-11-21 14:51:37 -08:00
Kelly Brazil
b5c22c6e53 add deb-packages-index parser 2023-11-21 14:40:43 -08:00
Kelly Brazil
7951366117 remove old unused line 2023-11-17 12:06:43 -08:00
Kelly Brazil
c78a4bb655 mount fix for spaces in mountpoint name 2023-11-14 15:17:31 -08:00
Kelly Brazil
8aceda18b9 Merge pull request #483 from wolkenarchitekt/master
#482 Quickfix to parse mount output
2023-11-14 23:07:52 +00:00
Ingo Weinmann
e0c75a9b6b #482 Quickfix to parse mount output 2023-11-14 22:47:56 +01:00
Kelly Brazil
fd283f6cf7 doc update 2023-11-04 16:02:02 -07:00
Kelly Brazil
b881ad4ec0 make blank target null 2023-11-04 15:58:12 -07:00
Kelly Brazil
2fcb32e26f add debian/ubuntu package index support 2023-11-04 15:19:12 -07:00
Kelly Brazil
13a802225b add tests 2023-10-25 16:53:24 -07:00
Kelly Brazil
88649a4e8d doc update 2023-10-25 13:42:19 -07:00
Kelly Brazil
5c6fa5bff6 better header row detection 2023-10-25 13:37:59 -07:00
Kelly Brazil
b70025d6d6 fix for blank target in rule 2023-10-24 16:17:53 -07:00
Kelly Brazil
59b89ecbd4 version bump 2023-10-24 15:24:33 -07:00
Kelly Brazil
8f7502ff0f Merge pull request #479 from kellyjonbrazil/master
sync to dev
2023-10-24 22:22:31 +00:00
Kelly Brazil
249d93f15c Merge pull request #477 from kellyjonbrazil/dev
v1.23.6
2023-10-24 00:57:57 +00:00
Kelly Brazil
b0cf2e2d78 clean up final return 2023-10-23 17:37:53 -07:00
Kelly Brazil
264fcd40ad clear linedata if 'from' found 2023-10-23 17:36:25 -07:00
Kelly Brazil
54def8ef49 doc update 2023-10-23 15:41:11 -07:00
Kelly Brazil
63c271b837 add tests 2023-10-23 15:39:13 -07:00
Kelly Brazil
741b2d1c1d version bump 2023-10-23 15:15:07 -07:00
Kelly Brazil
47d4335890 fix for multi-word remote 2023-10-23 15:14:28 -07:00
Kelly Brazil
81f721f1ab doc update 2023-10-23 14:33:40 -07:00
Kelly Brazil
c4e1068895 move print statements 2023-10-23 14:06:04 -07:00
Kelly Brazil
a77bb4165a fix tests for different xmltodict versions 2023-10-23 12:49:06 -07:00
Kelly Brazil
3cd2dce496 formatting 2023-10-23 08:01:50 -07:00
Kelly Brazil
46a8978740 doc update 2023-10-23 07:54:14 -07:00
Kelly Brazil
3161c48939 fix for older xmltodict library versions 2023-10-23 07:53:39 -07:00
Kelly Brazil
a89a9187f8 version bump 2023-10-23 07:53:16 -07:00
Kelly Brazil
d9e0aa5b93 Merge pull request #475 from kellyjonbrazil/master
Merge pull request #473 from kellyjonbrazil/dev
2023-10-23 14:48:55 +00:00
Kelly Brazil
d298e101e9 Merge pull request #473 from kellyjonbrazil/dev
Dev v1.23.5
2023-10-21 12:23:25 -07:00
Kelly Brazil
cea975d7f1 doc update 2023-10-21 12:12:43 -07:00
Kelly Brazil
1ed69f9e6a doc update and fix tests 2023-10-21 12:09:18 -07:00
Kelly Brazil
ab0e05ec82 only set colors if pygments is installed 2023-10-21 12:01:09 -07:00
Kelly Brazil
c16cce4bf0 add tests 2023-10-13 08:52:14 -07:00
Kelly Brazil
d3489536a1 add "7" as a netstat raw state 2023-10-12 17:25:40 -07:00
Sebastian Uhlik
041050ce28 Fix bug in split when program running on UDP contains space in name (#447)
* Add condition before split.

* Safe detection of 'state' presence.

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-10-12 17:21:06 -07:00
pettai
7de1a8a5d6 add more tests (#468)
add all test-cases
2023-10-05 17:09:35 -07:00
Kelly Brazil
d4604743d1 add multiline value support to env parser 2023-10-02 16:30:56 -07:00
Kelly Brazil
0b8fb31298 doc update 2023-10-02 08:35:36 -07:00
Kelly Brazil
dcdd79e28c doc update 2023-10-02 08:34:14 -07:00
Kelly Brazil
5291baeb8e fixup variable names 2023-10-02 08:32:41 -07:00
Kelly Brazil
6867102c66 doc update 2023-10-01 18:13:27 -07:00
Kelly Brazil
36ed2c7e2e add lsb_release parser 2023-10-01 18:12:22 -07:00
Kelly Brazil
4ab0aba9d3 doc update 2023-10-01 17:42:42 -07:00
Kelly Brazil
e643badaf7 add os-release parser 2023-10-01 17:42:00 -07:00
Kelly Brazil
d96e96219e add comment support to xml parser 2023-10-01 11:49:50 -07:00
Kelly Brazil
e42af3353e fix pidstat parsers for -T ALL option 2023-10-01 11:25:56 -07:00
Kelly Brazil
4ec2b16f42 doc fix 2023-09-30 16:18:32 -07:00
Kelly Brazil
0a028456bf add nsd-control parser 2023-09-30 15:45:29 -07:00
pettai
a1f10928e1 Add nsd-control (#454)
* Create nsd_control.py

Init nsd_control.py

* cleanup nsd-control + add test data

- Cleanup nsd-control parser
- Add test data

* add test script

add test script + fix test data

* Update test_nsd_control.py

fix a default test

* Update test_nsd_control.py

nit
2023-09-30 15:36:52 -07:00
Kelly Brazil
eae1d4b89a doc update 2023-09-30 15:34:29 -07:00
Kelly Brazil
d3c7cec333 add host parser 2023-09-30 15:32:27 -07:00
pettai
36fa08d711 Add ISC 'host' support (#450)
* Add ISC 'host' support

Add ISC 'host' command support

* Update host.py

remove leading tab from string

* Add integer conversion

Per request, fix integer conversion

* Cleanup

Cleanup strip()'s

* Add tests

Add two tests for the 'host' parser

* Update test_host.py

nit

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:26:03 -07:00
Kelly Brazil
a9958841e4 doc update 2023-09-30 15:23:29 -07:00
Kelly Brazil
504ad81a01 version bump 2023-09-30 15:21:29 -07:00
Kevin Lyter
8bf2f4f4d0 [xrandr] Fix 453 devices issue (#455)
* [xrandr] Fix bug 453, clean up data model

* Fix: 'devices' was originally not a list, just assigned each time it
was parsed. Made that a list and appended to it.
* Removed distinction between unassociated/associated devices
* Added test for @marcin-koziol's problem
* Put tests into separate test methods

* Formatting cleanup

* Backwards compatible type syntax

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:19:14 -07:00
Kelly Brazil
805397ea18 doc update 2023-09-30 15:15:29 -07:00
Samson Umezulike
1b3985c2d7 Adds graceful handling of superfluous bits in bit strings (#459)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:12:18 -07:00
Kelly Brazil
f602043642 fix for negative serial numbers 2023-09-30 15:06:28 -07:00
Samson Umezulike
1a1aa8fda3 Adds graceful handling of negative serial numbers in x509 certificates (#445)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:02:55 -07:00
Kelly Brazil
3249a017ae add dest-unreachable test 2023-09-15 12:09:38 -07:00
Kelly Brazil
84f0246b2d move int/float conversions to _process 2023-09-14 18:15:28 -07:00
Kelly Brazil
1c795982b0 add error and corrupted fields to ping-s 2023-09-14 13:03:45 -07:00
Kelly Brazil
c5164b4108 doc update 2023-09-10 15:20:11 -07:00
Kelly Brazil
dc3716ecb3 add errors and corrupted support 2023-09-10 15:18:32 -07:00
Kelly Brazil
c5165ccc21 version bump 2023-09-10 15:18:23 -07:00
José Miguel Guzmán
5b2035e0e6 Add support for corrupted and errors in linux ping. (#442)
* Add support for corrupted and errors in linux ping.

* Fix regular expressions

* Workaround to keep compatibility with current tests

---------

Co-authored-by: Jose Miguel Guzman <jmguzman@whitestack.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-08-25 10:31:17 -07:00
Kelly Brazil
5205154aaf add percent_wait to float conversion 2023-08-21 17:18:07 -07:00
Kelly Brazil
f500de3af6 version bump 2023-08-21 17:17:34 -07:00
Kian-Meng Ang
4b028b5080 Fix typos (#440)
Found via `codespell -S ./tests/fixtures -L chage,respons,astroid,unx,ist,technik,ans,buildd`
2023-07-31 08:45:03 -07:00
Kelly Brazil
4cd721be85 Dev v1.23.4 (#439)
* version bump

* fix regex for crlf line endings

* Completed Ip_route parser (#429)

* tests

* Merge pull request #398 from kellyjonbrazil/dev

Dev v1.23.2

* Merge pull request #398 from kellyjonbrazil/dev

Dev v1.23.2

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
Co-authored-by: Jjack3032 <julian.jackson@parsons.us>

* formatting

* doc update

* use splitlines

* formatting

* formatting

* Parser for `find` linux command (#434)

* Added find parser and tests for Centos 7.7 and Ubuntu 18.04

* Added a test file, changed logic, and included a case for permission denied returned by find.

* Added a few more lines to the tests

* Changed logic for setting values to null and updated test cases.

* doc update

* doc update

* Added proc_net_tcp parser (#421)

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>

* clean up net_tcp parser

* add resolve.conf test files

* doc update

* add resolve.conf parser

* doc update

* add sortlist functionality

* add resolve.conf parser tests

* doc update

---------

Co-authored-by: Julian5555 <58196809+Julian5555@users.noreply.github.com>
Co-authored-by: Jjack3032 <julian.jackson@parsons.us>
Co-authored-by: solomonleang <124934439+solomonleang@users.noreply.github.com>
Co-authored-by: AlvinSolomon <41175627+AlvinSolomon@users.noreply.github.com>
2023-07-30 10:08:39 -07:00
Kelly Brazil
d58ca402a7 Merge pull request #432 from kellyjonbrazil/revert-430-find_parser
Revert "Added find parser and tests for Centos 7.7 and Ubuntu 18.04"
2023-06-23 15:40:06 +00:00
Kelly Brazil
5386879040 Revert "Added find parser and tests for Centos 7.7 and Ubuntu 18.04 (#430)"
This reverts commit f19a1f23a9.
2023-06-23 08:39:12 -07:00
solomonleang
f19a1f23a9 Added find parser and tests for Centos 7.7 and Ubuntu 18.04 (#430)
* Added find parser and tests for Centos 7.7 and Ubuntu 18.04

* Added a test file, changed logic, and included a case for permission denied returned by find.

* Added a few more lines to the tests

* Changed logic for setting values to null and updated test cases.
2023-06-23 08:38:56 -07:00
Kelly Brazil
5023e5be4c 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-21 15:48:23 -07:00
631 changed files with 51880 additions and 2337 deletions

View File

@@ -14,12 +14,12 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-20.04, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: "Set up timezone to America/Los_Angeles"
uses: szenius/set-timezone@v1.0
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ build/
.github/
.vscode/
_config.yml
.venv

102
CHANGELOG
View File

@@ -1,5 +1,107 @@
jc changelog
20240212 v1.25.1
- Fix for crash when optional libraries are not installed (e.g. xmltodict)
- Fix for `ini` parser crashing with some keys with no values
- Fix `xrandr` parser to extract more EDID data
- Enhance `uptime` parser to support output with no user information
- Enhance `--quiet` CLI option to cover more warning messages
- Add tests for missing optional libraries
- Documentation updates
20240204 v1.25.0
- Add `--slurp` functionality to wrap output from multiple lines into a single array.
Note, this only works with single-line input parsers. (e.g. `date`, `ip-address`, `url`, etc.)
Streaming parsers are not supported. Use `jc -hhh` to find parsers compatible with the slurp option.
- Enhance `/proc` file magic syntax to allow slurping when multiple files are selected
and to include the `_file` metadata field in the data
- Enhance `--meta-out` functionality to include a list of the input data when using `--slurp`
or `/proc` file magic syntax. For slurpable parsers, this is a list of string inputs in order.
For `/proc` file magic syntax, this is a list of `/proc` filenames in order. This can help with
identifying which input matches to which output when using `--slurp` or when converting multiple
files via `/proc` file magic syntax.
- Add `curl-head` command parser for `curl --head` or `curl -I` with verbose support
- Add `efibootmgr` command parser
- Add `http-headers` parser for plain HTTP header output
- Add `kv-dup` parser for Key/Value files with duplicate keys
- Add `path` string parser to parse posix path
- Add `path-list` string parser to parse path list strings found in env variables
- Add source link to online parser documentation
- Add snap package build scripts
- Add `remove_quotes` function to `utils.py`
- Add `normalize_key` function to `utils.py`
- Add `line_slice` function to `utils.py`
- Add `get_parser` function to `lib.py`
- Enhance `nsd-control` parser to support more zone information
- Enhance `ping` and `ping-s` parsers to support the `-I` command option
- Enhance `proc-net-tcp` parser to add opposite endian support for architectures
like the s390x
- Enhance `url` parser to add `parent`, `filename`, `stem`, and `extension` fields
- Fix `ini` and `ini-dup` parsers to consistently handle null values as empty strings
- Fix line slicer to not skip blank lines
- Refactor parser aliases for `kv`, `pkg_index_deb`, `lsb_release`, and `os-release`
- Update copyright date
20231216 v1.24.0
- Add `debconf-show` command parser
- Add `iftop` command parser
- Add `pkg-index-apk` parser for Alpine Linux Package Index files
- Add `pkg-index-deb` parser for Debian/Ubuntu Package Index files
- Add `proc-cmdline` parser for `/proc/cmdline` file
- Add `swapon` command parser
- Add `tune2fs` command parser
- Remove `iso-datetime` parser deprecated since v1.22.1. (use `datetime-iso` instead)
- Update timezone change in Github Actions for node v16 requirement
- Add Python 3.12 tests to Github Actions
- Refactor `acpi` command parser for code cleanup
- Refactor vendored libraries to remove Python 2 support
- Fix `iptables` parser for cases where the `target` field is blank in a rule
- Fix `vmstat` parsers for some cases where wide output is used
- Fix `mount` parser for cases with spaces in the mount point name
- Fix `xrandr` parser for infinite loop issues
20231023 v1.23.6
- Fix XML parser for xmltodict library versions < 0.13.0
- Fix `who` command parser for cases when the from field contains spaces
20231021 v1.23.5
- Add `host` command parser
- Add `nsd-control` command parser
- Add `lsb_release` command parser
- Add `/etc/os-release` file parser
- Enhance `env` command parser to support multi-line values
- Enhance `ping` and `ping-s` parsers to add error and corrupted support
- Enhance `xml` parser to include comments in the JSON output
- Fix `pidstat` command parser when using `-T ALL`
- Fix `x509-cert` parser to allow negative serial numbers
- Fix `x509-cert` parser for cases when bitstrings are larger than standard
- Fix `xrandr` command parser for associated device issues
- Fix error when pygments library is not installed
20230730 v1.23.4
- Add `/etc/resolve.conf` file parser
- Add `/proc/net/tcp` and `/proc/net/tcp6` file parser
- Add `find` command parser
- Add `ip route` command parser
- Fix `certbot` command parser to be more robust with different line endings
20230621 v1.23.3
- Add `lsattr` command parser
- Add `srt` file parser
- Add `veracrypt` command parser
- Add X509 Certificate Request file parser
- Enhance X509 Certificate parser to allow non-compliant email addresses with a warning
- Enhance `dig` command parser to support the `+nsid` option
- Enhance `last` and `lastb` command parser to support the `-x` option
- Enhance `route` command parser to add Windows support
- Enhnace `netstat` command parser to add Windows support
- Enhance `ss` command parser to support extended options
- Enhance the compatibility warning message
- Fix `bluetoothctl` command parser for some mouse devices
- Fix `ping` command parsers for output with missing hostname
- Fix `stat` command parser for older versions that may not contain all fields
- Fix deprecated option in `setup.cfg`
20230429 v1.23.2
- Add `bluetoothctl` command parser
- Add `certbot` command parser for `certificates` and `show_account` options

View File

@@ -1,5 +1,6 @@
# Contributing to jc
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
We love your input! We want to make contributing to this project as easy and
transparent as possible, whether it's:
- Reporting a bug
- Discussing the current state of the code
@@ -8,26 +9,65 @@ We love your input! We want to make contributing to this project as easy and tra
- Proposing a new parser
## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
We use github to host code, to track issues and feature requests, as well as
accept pull requests.
## We Use Github Flow, So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
Pull requests are the best way to propose changes to the codebase (we use
[Github Flow](https://guides.github.com/introduction/flow/index.html)). We
actively welcome your pull requests:
1. Open an issue to discuss the new feature, bug fix, or parser before opening a pull request. For new parsers, it is important to agree upon a schema before developing the parser.
2. Fork the repo and create your branch from `dev`, if available, otherwise `master`.
3. For new parsers: Use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template to get started. You can even place a new parser python module file in the [parser plugin directory](https://github.com/kellyjonbrazil/jc#custom-parsers) to get started right away with just a standard `jc` installation.
4. If you've added code that should be tested, add tests. All new parsers should have several sample outputs and tests.
5. Documentation is auto-generated from docstrings, so ensure they are clear and accurate.
6. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone should be configured on the test system)
1. Open an issue to discuss the new feature, bug fix, or parser before opening
a pull request. For new parsers, it is important to agree upon a schema
before developing the parser.
2. Fork the repo and create your branch from `dev`, if available, otherwise
`master`.
3. For new parsers:
- Templates: Use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py)
parsers as a template to get started.
- Local development: You can even place a new parser python module file in
the [parser plugin directory](https://github.com/kellyjonbrazil/jc#parser-plugins)
to get started right away with just a standard `jc` installation.
- Parser registry: Add the parser name to the [jc/lib.py](https://github.com/kellyjonbrazil/jc/blob/master/jc/lib.py)
file.
4. If you've added code that should be tested, add tests. All new parsers should
have several sample outputs and tests.
- Templates:
- **Recommended:** [tests/templates/_test_foo_simple.py](https://github.com/kellyjonbrazil/jc/tree/master/tests/templates/_test_foo_simple.py) as a template if you only have test with fixtures.
Execute these steps for standard tests:
- Save this file as `test_{parser_name}.py` since the helper methods extract parser names from the filename. Use underscores instead of dashes for the parser name.
- Organize fixtures in `tests/fixtures` for optimal structure.
- Format fixtures as follows (using double dashes):
- `{parser_name}--{some_test_description}.out` for command output. (no dots in the filename except for the `.out` suffix)
- `{parser_name}--{some_test_description}.json` for expected JSON after parsing. (no dots in the filename except for the `.json` suffix)
- Custom: [tests/templates/_test_foo.py](https://github.com/kellyjonbrazil/jc/blob/master/tests/templates/_test_foo.py) as a template for tests.
- Custom: [tests/templates/_test_foo_s.py](https://github.com/kellyjonbrazil/jc/tree/master/tests/templates/_test_foo_s.py) as a template for **streaming parser** tests.
- Fixtures: Tests typically consist of an input file and an expected output
JSON file. Add the data files to the appropriate folder under [tests/fixtures](https://github.com/kellyjonbrazil/jc/tree/master/tests/fixtures)
5. Documentation is auto-generated from docstrings, so ensure they are clear and
accurate.
6. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone
should be configured on the test system)
7. Make sure your code lints.
8. Issue that pull request!
## Parser Schema Guidelines
- Try to keep the schema as flat as possible - typically a list of flat dictionaries
- Keys should be lowercase, contain no special characters, and spaces should be converted to underscores
- Keys should be static, if possible. If they have to be dynamic, then they should not contain lists or dictionaries
## Documentation And Completions
This will make it easier to use tools like `jq` without requiring escaping of special characters, encapsulating key names in [""], keeps paths predictable, and makes iterating and searching for values easier.
No need to worry about documentation and completions as those are auto generated
via the python doc strings.
## Parser Schema Guidelines
- Try to keep the schema as flat as possible - typically a list of flat
dictionaries
- Keys should be lowercase, contain no special characters, and spaces should be
converted to underscores
- Keys should be static, if possible. If they have to be dynamic, then they
should not contain lists or dictionaries
This will make it easier to use tools like `jq` without requiring escaping of
special characters, encapsulating key names in `[""]`, keeps paths predictable,
and makes iterating and searching for values easier.
**Examples**
@@ -62,18 +102,61 @@ Good:
]
```
## Tests
It is essential to have good command output sample coverage and tests to keep the `jc` parser quality high.
## Development Environment
Use the following steps to set up the development environment.
Many parsers include calculated timestamp fields using the `jc.utils.timestamp` class. Naive timestamps created with this class should be generated on a system configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and "**Pacific Standard Time**" timezone on Windows for tests to pass on the Github Actions CI tests. This timezone should be configured on your local system before running the tests locally, as well.
### Virtual Environment
Set up a Python virtual environment for `jc` development so you won't have to
worry about library conflicts. This can be done with something like
[pyenv](https://github.com/pyenv/pyenv) and/or
[venv](https://docs.python.org/3/library/venv.html)
### Clone the repo
Once the virtual environment is set up, clone the `jc` repository inside:
```bash
git clone https://github.com/kellyjonbrazil/jc.git
```
### Install In Developer Mode
Next, use the `./install.sh` script to install `jc` and the requirements in
developer mode (code chages take effect immediately). This will install the
console-script entry point to `$HOME/.local/bin` so you may need to add this
to your path.
## Tests
It is essential to have good command output sample coverage and tests to keep
the `jc` parser quality high.
Many parsers include calculated timestamp fields using the `jc.utils.timestamp`
class. Naive timestamps created with this class should be generated on a system
configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and
"**Pacific Standard Time**" timezone on Windows for tests to pass on the Github
Actions CI tests. This timezone should be configured on your local system before
running the tests locally, as well.
You can run all tests by running the `./runtests.sh` script.
## Debug Messages
Use `--debug` or `-d` to see debug error messages (double to see more):
```shell
echo 'abc' | jc --parser-with-error -dd
```
## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
In short, when you submit code changes, your submissions are understood to be
under the same [MIT License](http://choosealicense.com/licenses/mit/) that
covers the project. Feel free to contact the maintainers if that's a concern.
## Report bugs using Github's Issues
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that easy!
We use GitHub issues to track public bugs. Report a bug by
[opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that
easy!
## Write bug reports with detail, background, and sample code
**Great Bug Reports** tend to have:
- A quick summary and/or background
@@ -82,8 +165,10 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
- Notes (possibly including why you think this might be happening, or stuff you
tried that didn't work)
## Use a Consistent Coding Style
* 4 spaces for indentation rather than tabs
* Use a Python linter that will enforce PEP 8 and other best practices

View File

@@ -4551,6 +4551,57 @@ cat entrust.pem | jc --x509-cert -p
}
]
```
### X.509 PEM and DER certificate request files
```bash
cat myserver.csr | jc --x509-csr -p
```
```json
[
{
"certification_request_info": {
"version": "v1",
"subject": {
"common_name": "myserver.for.example"
},
"subject_pk_info": {
"algorithm": {
"algorithm": "ec",
"parameters": "secp256r1"
},
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2c:a4:35:1f:0f:54:c8:a9:9b:e3:9e:d4:f3:64:b8:60:cc:7f:39:75:dd:a7:61:31:02:7c:9e:89:c6:db:45:15:f2:5f:b0:65:29:0b:42:d2:6e:c2:ea:a6:23:bd:fc:65:e5:7d:4e"
},
"attributes": [
{
"type": "extension_request",
"values": [
[
{
"extn_id": "extended_key_usage",
"critical": false,
"extn_value": [
"server_auth"
]
},
{
"extn_id": "subject_alt_name",
"critical": false,
"extn_value": [
"myserver.for.example"
]
}
]
]
}
]
},
"signature_algorithm": {
"algorithm": "sha384_ecdsa",
"parameters": null
},
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:8a:fe:95:98:98:98:a9:45:34:31:08:ff:2c:cc:92:d9:1c:70:28:74:02:21:00:97:79:7b:e7:45:18:76:cf:d7:3b:79:34:56:d2:69:b5:73:41:9b:8a:b7:ad:ec:80:23:c1:2f:64:da:e5:28:19"
}
]
```
### XML files
```bash
cat cd_catalog.xml

75
README-snap.md Normal file
View File

@@ -0,0 +1,75 @@
# How to use `jc` with `snap`
## How to build `snap` package
- Install `snapd`. [One](https://snapcraft.io/docs/installing-snapd) or [two](https://github.com/don-rumata/ansible-role-install-snap).
- Install `snapcraft`:
```bash
$ sudo snap install snapcraft --classic
```
- Update snapd:
```bash
$ sudo snap refresh snapcraft --edge
```
- Clone the repo:
```bash
$ git clone https://github.com/kellyjonbrazil/jc
```
- Change the directory:
```bash
$ cd ./jc
```
- Select branch:
```bash
$ git checkout snap-support
```
- Initialize LXD:
```bash
$ lxd init --auto
```
- Build `.snap` file:
```bash
$ snapcraft
```
## How to install local snap file
```bash
$ snap install --dangerous ./jc_*_amd64.snap
```
## How to use `jc` with plugins
- Put your plugin in the `"$HOME/.local/share/jc"` directory.
- To connect the directory, run:
```bash
snap connect jc:dot-jc-plugins snapd
```
## Urls
- <https://snapcraft.io/docs/supported-interfaces>
- <https://snapcraft.io/docs/interface-management>
- <https://snapcraft.io/docs/personal-files-interface>
- <https://snapcraft.io/docs/python-apps>
- <https://documentation.ubuntu.com/lxd/en/latest/getting_started/>

115
README.md
View File

@@ -5,8 +5,9 @@
> Try the `jc` [web demo](https://jc-web.onrender.com/) and [REST API](https://github.com/kellyjonbrazil/jc-restapi)
> JC is [now available](https://galaxy.ansible.com/community/general) as an
Ansible filter plugin in the `community.general` collection. See this
> `jc` is available as an
[Ansible filter plugin](https://docs.ansible.com/ansible/latest/collections/community/general/jc_filter.html#ansible-collections-community-general-jc-filter)
in the `community.general` collection. See this
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
for an example.
@@ -118,6 +119,7 @@ pip3 install jc
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
| Guix System linux | `guix install jc` |
| Gentoo Linux | `emerge dev-python/jc` |
| Photon linux | `tdnf install jc` |
| macOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
@@ -174,17 +176,21 @@ option.
| `--crontab-u` | `crontab` file parser with user support | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u) |
| `--csv` | CSV file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv) |
| `--csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
| `--curl-head` | `curl --head` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/curl_head) |
| `--date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
| `--datetime-iso` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/datetime_iso) |
| `--debconf-show` | `debconf-show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/debconf_show) |
| `--df` | `df` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/df) |
| `--dig` | `dig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dig) |
| `--dir` | `dir` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dir) |
| `--dmidecode` | `dmidecode` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode) |
| `--dpkg-l` | `dpkg -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l) |
| `--du` | `du` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/du) |
| `--efibootmgr` | `efibootmgr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/efibootmgr) |
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
| `--env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
| `--file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
| `--find` | `find` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/find) |
| `--findmnt` | `findmnt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/findmnt) |
| `--finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
| `--free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
@@ -199,7 +205,9 @@ option.
| `--hashsum` | hashsum command parser (`md5sum`, `shasum`, etc.) | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum) |
| `--hciconfig` | `hciconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig) |
| `--history` | `history` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/history) |
| `--host` | `host` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/host) |
| `--hosts` | `/etc/hosts` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
| `--http-headers` | HTTP headers parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/http_headers) |
| `--id` | `id` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/id) |
| `--ifconfig` | `ifconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig) |
| `--ini` | INI file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ini) |
@@ -208,15 +216,19 @@ option.
| `--iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
| `--ip-address` | IPv4 and IPv6 Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_address) |
| `--iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
| `--ip-route` | `ip route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_route) |
| `--iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
| `--iwconfig` | `iwconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iwconfig) |
| `--jar-manifest` | Java MANIFEST.MF file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
| `--jobs` | `jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs) |
| `--jwt` | JWT string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jwt) |
| `--kv` | Key/Value file and string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
| `--kv-dup` | Key/Value with duplicate key file and string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv_dup) |
| `--last` | `last` and `lastb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
| `--ls` | `ls` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
| `--ls-s` | `ls` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s) |
| `--lsattr` | `lsattr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsattr) |
| `--lsb-release` | `lsb_release` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsb_release) |
| `--lsblk` | `lsblk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk) |
| `--lsmod` | `lsmod` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
| `--lsof` | `lsof` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
@@ -229,10 +241,14 @@ option.
| `--mpstat-s` | `mpstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
| `--netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
| `--nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
| `--nsd-control` | `nsd-control` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nsd_control) |
| `--ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
| `--openvpn` | openvpn-status.log file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/openvpn) |
| `--os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
| `--os-release` | `/etc/os-release` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_release) |
| `--passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
| `--path` | POSIX path string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/path) |
| `--path-list` | POSIX path list string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/path_list) |
| `--pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
| `--pgpass` | PostgreSQL password file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pgpass) |
| `--pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
@@ -241,10 +257,13 @@ 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-apk` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_apk) |
| `--pkg-index-deb` | Debian Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_deb) |
| `--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) |
| `--ps` | `ps` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
| `--resolve-conf` | `/etc/resolve.conf` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/resolve_conf) |
| `--route` | `route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
| `--rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
| `--rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
@@ -252,11 +271,13 @@ option.
| `--semver` | Semantic Version string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/semver) |
| `--sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
| `--shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
| `--srt` | SRT file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/srt) |
| `--ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
| `--ssh-conf` | `ssh` config file and `ssh -G` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ssh_conf) |
| `--sshd-conf` | `sshd` config file and `sshd -T` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sshd_conf) |
| `--stat` | `stat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
| `--stat-s` | `stat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
| `--swapon` | `swapon` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/swapon) |
| `--sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
| `--syslog` | Syslog RFC 5424 string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/syslog) |
| `--syslog-s` | Syslog RFC 5424 string streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/syslog_s) |
@@ -275,6 +296,7 @@ option.
| `--top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
| `--tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
| `--traceroute` | `traceroute` and `traceroute6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
| `--tune2fs` | `tune2fs -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tune2fs) |
| `--udevadm` | `udevadm info` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/udevadm) |
| `--ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
| `--ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
@@ -285,12 +307,14 @@ option.
| `--uptime` | `uptime` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
| `--url` | URL string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/url) |
| `--ver` | Version string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ver) |
| `--veracrypt` | `veracrypt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/veracrypt) |
| `--vmstat` | `vmstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
| `--vmstat-s` | `vmstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
| `--w` | `w` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
| `--wc` | `wc` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) |
| `--who` | `who` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/who) |
| `--x509-cert` | X.509 PEM and DER certificate file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_cert) |
| `--x509-csr` | X.509 PEM and DER certificate request file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_csr) |
| `--xml` | XML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) |
| `--xrandr` | `xrandr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) |
| `--yaml` | YAML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) |
@@ -300,22 +324,23 @@ option.
### Options
| Short | Long | Description |
|-------|-----------------|---------------------------------------------------------------------------------------------------------------------|
| `-a` | `--about` | About `jc`. Prints information about `jc` and the parsers (in JSON or YAML, of course!) |
| `-C` | `--force-color` | Force color output even when using pipes (overrides `-m` and the `NO_COLOR` env variable) |
| `-d` | `--debug` | Debug mode. Prints trace messages if parsing issues are encountered (use`-dd` for verbose debugging) |
| `-h` | `--help` | Help. Use `jc -h --parser_name` for parser documentation. Use twice to show hidden parsers (e.g. `-hh`) |
| `-m` | `--monochrome` | Monochrome output |
| `-M` | `--meta-out` | Add metadata to output including timestamp, parser name, magic command, magic command exit code, etc. | |
| `-p` | `--pretty` | Pretty format the JSON output |
| `-q` | `--quiet` | Quiet mode. Suppresses parser warning messages (use `-qq` to ignore streaming parser errors) |
| `-r` | `--raw` | Raw output. Provides more literal output, typically with string values and no additional semantic processing |
| `-u` | `--unbuffer` | Unbuffer output |
| `-v` | `--version` | Version information |
| `-y` | `--yaml-out` | YAML output |
| `-B` | `--bash-comp` | Generate Bash shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
| `-Z` | `--zsh-comp` | Generate Zsh shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
| Short | Long | Description |
|-------|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-a` | `--about` | About `jc`. Prints information about `jc` and the parsers (in JSON or YAML, of course!) |
| `-C` | `--force-color` | Force color output even when using pipes (overrides `-m` and the `NO_COLOR` env variable) |
| `-d` | `--debug` | Debug mode. Prints trace messages if parsing issues are encountered (use`-dd` for verbose debugging) |
| `-h` | `--help` | Help. Use `jc -h --parser_name` for parser documentation. Use twice to show hidden parsers (e.g. `-hh`). Use thrice to show parser categories (e.g. `-hhh`). |
| `-m` | `--monochrome` | Monochrome output |
| `-M` | `--meta-out` | Add metadata to output including timestamp, parser name, magic command, magic command exit code, etc. | |
| `-p` | `--pretty` | Pretty format the JSON output |
| `-q` | `--quiet` | Quiet mode. Suppresses parser warning messages (use `-qq` to ignore streaming parser errors) |
| `-r` | `--raw` | Raw output. Provides more literal output, typically with string values and no additional semantic processing |
| `-s` | `--slurp` | Slurp multiple lines into an array. (use `-hhh` to find compatible parsers) |
| `-u` | `--unbuffer` | Unbuffer output |
| `-v` | `--version` | Version information |
| `-y` | `--yaml-out` | YAML output |
| `-B` | `--bash-comp` | Generate Bash shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
| `-Z` | `--zsh-comp` | Generate Zsh shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
### Slice
Line slicing is supported using the `START:STOP` syntax similar to Python
@@ -365,6 +390,58 @@ Here is a breakdown of line slice options:
| `:-STOP` | lines from the beginning through `STOP` lines from the end |
| `:` | all lines |
### 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. `url` and `ip-address`) To see a list of parsers that support
the `--slurp` option, use `jc -hhh`.
For example, you can send a file with multiple IP addresses (one per line) to
`jc` with the `--slurp` option and an array of results will output:
```bash
$ cat ip-addresses.txt | jc --slurp --ip-address
[<multiple output objects>]
```
The magic syntax for `/proc` files automatically supports slurping of multiple
files (no need to use the `--slurp` option). For example, you can convert many
PID files at once:
```bash
$ jc /proc/*/status
[<multiple output objects>]
```
When the `/proc` magic syntax is used and multiple files are selected, an
additional `_file` field is inserted in the output so it is easier to tell what
file each output object refers to.
Finally, the `--meta-out` option can be used in conjunction with slurped output.
In this case, the slurped output is wrapped in an object with the following
structure:
```json
{
"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"
]
}
}
```
With `--meta-out`, `input_list` contains a list of inputs (actual input strings
or `/proc` filenames) so you can identify which output object relates to each
input string or `/proc` filename.
### Exit Codes
Any fatal errors within `jc` will generate an exit code of `100`, otherwise the
exit code will be `0`.
@@ -1294,4 +1371,4 @@ cat istio.yaml | jc -p --yaml
]
```
© 2019-2023 Kelly Brazil
© 2019-2024 Kelly Brazil

View File

@@ -3,9 +3,9 @@ _jc()
local cur prev words cword jc_commands jc_parsers jc_options \
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 df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw iwconfig jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli 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 sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo zpool)
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 --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --os-prober --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-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 --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --ssh-conf --sshd-conf --stat --stat-s --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 --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --vmstat --vmstat-s --w --wc --who --x509-cert --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_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr 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 --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --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 --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --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 --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --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 --slurp -s --unbuffer -u --yaml-out -y)
jc_about_options=(--about -a)
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
jc_help_options=(--help -h)

View File

@@ -9,7 +9,7 @@ _jc() {
jc_help_options jc_help_options_describe \
jc_special_options jc_special_options_describe
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw iwconfig jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli 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 sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo zpool)
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr 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_commands_describe=(
'acpi:run "acpi" command with magic syntax.'
'airport:run "airport" command with magic syntax.'
@@ -21,12 +21,15 @@ _jc() {
'chage:run "chage" command with magic syntax.'
'cksum:run "cksum" command with magic syntax.'
'crontab:run "crontab" command with magic syntax.'
'curl:run "curl" command with magic syntax.'
'date:run "date" command with magic syntax.'
'debconf-show:run "debconf-show" command with magic syntax.'
'df:run "df" command with magic syntax.'
'dig:run "dig" command with magic syntax.'
'dmidecode:run "dmidecode" command with magic syntax.'
'dpkg:run "dpkg" command with magic syntax.'
'du:run "du" command with magic syntax.'
'efibootmgr:run "efibootmgr" command with magic syntax.'
'env:run "env" command with magic syntax.'
'file:run "file" command with magic syntax.'
'findmnt:run "findmnt" command with magic syntax.'
@@ -35,9 +38,11 @@ _jc() {
'git:run "git" command with magic syntax.'
'gpg:run "gpg" command with magic syntax.'
'hciconfig:run "hciconfig" command with magic syntax.'
'host:run "host" command with magic syntax.'
'id:run "id" command with magic syntax.'
'ifconfig:run "ifconfig" command with magic syntax.'
'iostat:run "iostat" command with magic syntax.'
'ip:run "ip" command with magic syntax.'
'iptables:run "iptables" command with magic syntax.'
'iw:run "iw" command with magic syntax.'
'iwconfig:run "iwconfig" command with magic syntax.'
@@ -45,6 +50,8 @@ _jc() {
'last:run "last" command with magic syntax.'
'lastb:run "lastb" command with magic syntax.'
'ls:run "ls" command with magic syntax.'
'lsattr:run "lsattr" command with magic syntax.'
'lsb_release:run "lsb_release" command with magic syntax.'
'lsblk:run "lsblk" command with magic syntax.'
'lsmod:run "lsmod" command with magic syntax.'
'lsof:run "lsof" command with magic syntax.'
@@ -57,6 +64,7 @@ _jc() {
'mpstat:run "mpstat" command with magic syntax.'
'netstat:run "netstat" command with magic syntax.'
'nmcli:run "nmcli" command with magic syntax.'
'nsd-control:run "nsd-control" command with magic syntax.'
'ntpq:run "ntpq" command with magic syntax.'
'os-prober:run "os-prober" command with magic syntax.'
'pidstat:run "pidstat" command with magic syntax.'
@@ -82,6 +90,7 @@ _jc() {
'sshd:run "sshd" command with magic syntax.'
'stat:run "stat" command with magic syntax.'
'sum:run "sum" command with magic syntax.'
'swapon:run "swapon" command with magic syntax.'
'sysctl:run "sysctl" command with magic syntax.'
'systemctl:run "systemctl" command with magic syntax.'
'systeminfo:run "systeminfo" command with magic syntax.'
@@ -91,6 +100,7 @@ _jc() {
'tracepath6:run "tracepath6" command with magic syntax.'
'traceroute:run "traceroute" command with magic syntax.'
'traceroute6:run "traceroute6" command with magic syntax.'
'tune2fs:run "tune2fs" command with magic syntax.'
'udevadm:run "udevadm" command with magic syntax.'
'ufw:run "ufw" command with magic syntax.'
'uname:run "uname" command with magic syntax.'
@@ -98,6 +108,7 @@ _jc() {
'upower:run "upower" command with magic syntax.'
'uptime:run "uptime" command with magic syntax.'
'vdir:run "vdir" command with magic syntax.'
'veracrypt:run "veracrypt" command with magic syntax.'
'vmstat:run "vmstat" command with magic syntax.'
'w:run "w" command with magic syntax.'
'wc:run "wc" command with magic syntax.'
@@ -106,7 +117,7 @@ _jc() {
'zipinfo:run "zipinfo" command with magic syntax.'
'zpool:run "zpool" command with magic syntax.'
)
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 --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --os-prober --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-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 --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --ssh-conf --sshd-conf --stat --stat-s --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 --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --vmstat --vmstat-s --w --wc --who --x509-cert --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 --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --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 --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --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 --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --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'
@@ -128,17 +139,21 @@ _jc() {
'--crontab-u:`crontab` file parser with user support'
'--csv:CSV file parser'
'--csv-s:CSV file streaming parser'
'--curl-head:`curl --head` command parser'
'--date:`date` command parser'
'--datetime-iso:ISO 8601 Datetime string parser'
'--debconf-show:`debconf-show` command parser'
'--df:`df` command parser'
'--dig:`dig` command parser'
'--dir:`dir` command parser'
'--dmidecode:`dmidecode` command parser'
'--dpkg-l:`dpkg -l` command parser'
'--du:`du` command parser'
'--efibootmgr:`efibootmgr` command parser'
'--email-address:Email Address string parser'
'--env:`env` command parser'
'--file:`file` command parser'
'--find:`find` command parser'
'--findmnt:`findmnt` command parser'
'--finger:`finger` command parser'
'--free:`free` command parser'
@@ -153,7 +168,9 @@ _jc() {
'--hashsum:hashsum command parser (`md5sum`, `shasum`, etc.)'
'--hciconfig:`hciconfig` command parser'
'--history:`history` command parser'
'--host:`host` command parser'
'--hosts:`/etc/hosts` file parser'
'--http-headers:HTTP headers parser'
'--id:`id` command parser'
'--ifconfig:`ifconfig` command parser'
'--ini:INI file parser'
@@ -162,15 +179,19 @@ _jc() {
'--iostat-s:`iostat` command streaming parser'
'--ip-address:IPv4 and IPv6 Address string parser'
'--iptables:`iptables` command parser'
'--ip-route:`ip route` command parser'
'--iw-scan:`iw dev [device] scan` command parser'
'--iwconfig:`iwconfig` command parser'
'--jar-manifest:Java MANIFEST.MF file parser'
'--jobs:`jobs` command parser'
'--jwt:JWT string parser'
'--kv:Key/Value file and string parser'
'--kv-dup:Key/Value with duplicate key file and string parser'
'--last:`last` and `lastb` command parser'
'--ls:`ls` command parser'
'--ls-s:`ls` command streaming parser'
'--lsattr:`lsattr` command parser'
'--lsb-release:`lsb_release` command parser'
'--lsblk:`lsblk` command parser'
'--lsmod:`lsmod` command parser'
'--lsof:`lsof` command parser'
@@ -183,10 +204,14 @@ _jc() {
'--mpstat-s:`mpstat` command streaming parser'
'--netstat:`netstat` command parser'
'--nmcli:`nmcli` command parser'
'--nsd-control:`nsd-control` command parser'
'--ntpq:`ntpq -p` command parser'
'--openvpn:openvpn-status.log file parser'
'--os-prober:`os-prober` command parser'
'--os-release:`/etc/os-release` file parser'
'--passwd:`/etc/passwd` file parser'
'--path:POSIX path string parser'
'--path-list:POSIX path list string parser'
'--pci-ids:`pci.ids` file parser'
'--pgpass:PostgreSQL password file parser'
'--pidstat:`pidstat -H` command parser'
@@ -195,10 +220,13 @@ _jc() {
'--ping-s:`ping` and `ping6` command streaming parser'
'--pip-list:`pip list` command parser'
'--pip-show:`pip show` command parser'
'--pkg-index-apk:Alpine Linux Package Index file parser'
'--pkg-index-deb:Debian Package Index file parser'
'--plist:PLIST file parser'
'--postconf:`postconf -M` command parser'
'--proc:`/proc/` file parser'
'--proc-buddyinfo:`/proc/buddyinfo` file parser'
'--proc-cmdline:`/proc/cmdline` file parser'
'--proc-consoles:`/proc/consoles` file parser'
'--proc-cpuinfo:`/proc/cpuinfo` file parser'
'--proc-crypto:`/proc/crypto` file parser'
@@ -237,6 +265,7 @@ _jc() {
'--proc-net-packet:`/proc/net/packet` file parser'
'--proc-net-protocols:`/proc/net/protocols` file parser'
'--proc-net-route:`/proc/net/route` file parser'
'--proc-net-tcp:`/proc/net/tcp` and `/proc/net/tcp6` file parser'
'--proc-net-unix:`/proc/net/unix` file parser'
'--proc-pid-fdinfo:`/proc/<pid>/fdinfo/<fd>` file parser'
'--proc-pid-io:`/proc/<pid>/io` file parser'
@@ -248,6 +277,7 @@ _jc() {
'--proc-pid-statm:`/proc/<pid>/statm` file parser'
'--proc-pid-status:`/proc/<pid>/status` file parser'
'--ps:`ps` command parser'
'--resolve-conf:`/etc/resolve.conf` file parser'
'--route:`route` command parser'
'--rpm-qi:`rpm -qi` command parser'
'--rsync:`rsync` command parser'
@@ -255,11 +285,13 @@ _jc() {
'--semver:Semantic Version string parser'
'--sfdisk:`sfdisk` command parser'
'--shadow:`/etc/shadow` file parser'
'--srt:SRT file parser'
'--ss:`ss` command parser'
'--ssh-conf:`ssh` config file and `ssh -G` command parser'
'--sshd-conf:`sshd` config file and `sshd -T` command parser'
'--stat:`stat` command parser'
'--stat-s:`stat` command streaming parser'
'--swapon:`swapon` command parser'
'--sysctl:`sysctl` command parser'
'--syslog:Syslog RFC 5424 string parser'
'--syslog-s:Syslog RFC 5424 string streaming parser'
@@ -278,6 +310,7 @@ _jc() {
'--top-s:`top -b` command streaming parser'
'--tracepath:`tracepath` and `tracepath6` command parser'
'--traceroute:`traceroute` and `traceroute6` command parser'
'--tune2fs:`tune2fs -l` command parser'
'--udevadm:`udevadm info` command parser'
'--ufw:`ufw status` command parser'
'--ufw-appinfo:`ufw app info [application]` command parser'
@@ -288,12 +321,14 @@ _jc() {
'--uptime:`uptime` command parser'
'--url:URL string parser'
'--ver:Version string parser'
'--veracrypt:`veracrypt` command parser'
'--vmstat:`vmstat` command parser'
'--vmstat-s:`vmstat` command streaming parser'
'--w:`w` command parser'
'--wc:`wc` command parser'
'--who:`who` command parser'
'--x509-cert:X.509 PEM and DER certificate file parser'
'--x509-csr:X.509 PEM and DER certificate request file parser'
'--xml:XML file parser'
'--xrandr:`xrandr` command parser'
'--yaml:YAML file parser'
@@ -301,7 +336,7 @@ _jc() {
'--zpool-iostat:`zpool iostat` command parser'
'--zpool-status:`zpool status` command parser'
)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y)
jc_options_describe=(
'--force-color:force color output (overrides -m)'
'-C:force color output (overrides -m)'
@@ -317,6 +352,8 @@ _jc() {
'-q:suppress warnings (double to ignore streaming errors)'
'--raw:raw output'
'-r:raw output'
'--slurp:slurp multiple lines into an array'
'-s:slurp multiple lines into an array'
'--unbuffer:unbuffer output'
'-u:unbuffer output'
'--yaml-out:YAML output'

View File

@@ -130,6 +130,14 @@ for parser in "${parsers[@]}"; do
echo "### Parser Information" >> ../docs/parsers/"${parser_name}".md
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
echo >> ../docs/parsers/"${parser_name}".md
echo "Source: [\`jc/parsers/${parser_name}.py\`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/${parser_name}.py)" >> ../docs/parsers/"${parser_name}".md
echo >> ../docs/parsers/"${parser_name}".md
if $(jq -e '.tags | contains(["slurpable"])' <<< "$parser"); then
echo "This parser can be used with the \`--slurp\` command-line option." >> ../docs/parsers/"${parser_name}".md
echo >> ../docs/parsers/"${parser_name}".md
fi
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
echo "+++ ${parser_name} docs complete"
fi

View File

@@ -1,11 +1,13 @@
# Table of Contents
* [jc.lib](#jc.lib)
* [get\_parser](#jc.lib.get_parser)
* [parse](#jc.lib.parse)
* [parser\_mod\_list](#jc.lib.parser_mod_list)
* [plugin\_parser\_mod\_list](#jc.lib.plugin_parser_mod_list)
* [standard\_parser\_mod\_list](#jc.lib.standard_parser_mod_list)
* [streaming\_parser\_mod\_list](#jc.lib.streaming_parser_mod_list)
* [slurpable\_parser\_mod\_list](#jc.lib.slurpable_parser_mod_list)
* [parser\_info](#jc.lib.parser_info)
* [all\_parser\_info](#jc.lib.all_parser_info)
* [get\_help](#jc.lib.get_help)
@@ -16,6 +18,38 @@
jc - JSON Convert lib module
<a id="jc.lib.get_parser"></a>
### get\_parser
```python
def get_parser(parser_mod_name: Union[str, ModuleType]) -> ModuleType
```
Return the parser module object and check that the module is a valid
parser module.
Parameters:
parser_mod_name: (string or Name of the parser module. This
Module) function will accept module_name,
cli-name, and --argument-name
variants of the module name.
If a Module is given and the Module
is a valid parser Module, then the
same Module is returned.
Returns:
Module: the parser Module object
Raises:
ModuleNotFoundError: If the Module is not found or is not a valid
parser Module, then a ModuleNotFoundError
exception is raised.
<a id="jc.lib.parse"></a>
### parse
@@ -59,15 +93,25 @@ To get a list of available parser module names, use `parser_mod_list()`.
Alternatively, a parser module object can be supplied:
>>> import jc
>>> import jc.parsers.date as jc_date
>>> jc_date = jc.get_parser('date')
>>> date_obj = jc.parse(jc_date, 'Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
You can also use the lower-level parser modules directly:
You can also use the parser modules directly via `get_parser()`:
>>> import jc
>>> jc_date = jc.get_parser('date')
>>> date_obj = jc_date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Finally, you can access the low-level parser modules manually:
>>> import jc.parsers.date
>>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> date_obj = jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Though, accessing plugin parsers directly is a bit more cumbersome, so
this higher-level API is recommended. Here is how you can access plugin
@@ -90,7 +134,7 @@ Parameters:
variants of the module name.
A Module object can also be passed
directly or via _get_parser()
directly or via get_parser()
data: (string or data to parse (string or bytes for
bytes or standard parsers, iterable of
@@ -156,6 +200,18 @@ def streaming_parser_mod_list(show_hidden: bool = False,
Returns a list of streaming parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.slurpable_parser_mod_list"></a>
### slurpable\_parser\_mod\_list
```python
def slurpable_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of slurpable parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.parser_info"></a>
### parser\_info

View File

@@ -250,4 +250,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/acpi.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/acpi.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -103,4 +103,6 @@ Returns:
### Parser Information
Compatibility: darwin
Source: [`jc/parsers/airport.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/airport.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -131,4 +131,6 @@ Returns:
### Parser Information
Compatibility: darwin
Source: [`jc/parsers/airport_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/airport_s.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -140,4 +140,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Source: [`jc/parsers/arp.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/arp.py)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -144,4 +144,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/asciitable.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/asciitable.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -129,4 +129,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/asciitable_m.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/asciitable_m.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/blkid.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/blkid.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -36,6 +36,7 @@ a controller and a device but there might be fields corresponding to one entity.
"name": string,
"is_default": boolean,
"is_public": boolean,
"is_random": boolean,
"address": string,
"alias": string,
"class": string,
@@ -54,8 +55,10 @@ a controller and a device but there might be fields corresponding to one entity.
{
"name": string,
"is_public": boolean,
"is_random": boolean,
"address": string,
"alias": string,
"appearance": string,
"class": string,
"icon": string,
"paired": string,
@@ -66,7 +69,8 @@ a controller and a device but there might be fields corresponding to one entity.
"legacy_pairing": string,
"rssi": int,
"txpower": int,
"uuids": array
"uuids": array,
"modalias": string
}
]
@@ -126,4 +130,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Jake Ob (iakopap at gmail.com)
Source: [`jc/parsers/bluetoothctl.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/bluetoothctl.py)
Version 1.1 by Jake Ob (iakopap at gmail.com)

View File

@@ -122,4 +122,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cbt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cbt.py)
Version 1.0 by Andreas Weiden (andreas.weiden@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cef.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cef.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -121,4 +121,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cef_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cef_s.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -158,4 +158,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/certbot.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/certbot.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -79,4 +79,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/chage.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/chage.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -77,4 +77,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/cksum.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cksum.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -196,4 +196,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/clf.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/clf.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -114,4 +114,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/clf_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/clf_s.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -32,7 +32,6 @@ Schema:
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
@@ -196,4 +195,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/crontab.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/crontab.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -29,7 +29,6 @@ Schema:
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
@@ -193,4 +192,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/crontab_u.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/crontab_u.py)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -102,4 +102,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/csv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -86,4 +86,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/csv_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv_s.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

309
docs/parsers/curl_head.md Normal file
View File

@@ -0,0 +1,309 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.curl_head"></a>
# jc.parsers.curl\_head
jc - JSON Convert `curl --head` command output parser
This parser converts standard and verbose `curl --head` output.
When converting verbose output from `curl` (to gather request headers, for
example) you will need to redirect STDERR to STDOUT with `2>&1`. The magic
syntax will not work in this case.
Usage (cli):
$ curl --head www.example.com | jc --curl-head
$ curl -Ivs www.example.com 2>&1 | jc --curl-head
or
$ jc curl --head www.example.com
Usage (module):
import jc
result = jc.parse('curl_head', curl_head_command_output)
Schema:
[
{
"_type": string, # request or response
"_request_method": string,
"_request_uri": string,
"_request_version": string,
"_response_version": string,
"_response_status": integer,
"_response_reason": string or null,
"<header>": string,
# well-known headers:
"accept": [
string
],
"accept-ch": [
string
],
"accept-ch-lifetime": integer,
"accept-encoding": [
string
],
"accept-language": [
string
],
"accept-patch": [
string
],
"accept-post": [
string
],
"accept-ranges": [
string
],
"access-control-allow-headers": [
string
],
"access-control-allow-methods": [
string
],
"access-control-expose-headers": [
string
],
"access-control-max-age": integer,
"access-control-request-headers": [
string
],
"age": integer,
"allow": [
string
],
"alt-svc": [
string
],
"cache-control": [
string
],
"clear-site-data": [
string
],
"connection": [
string
],
"content-encoding": [
string
],
"content-dpr": integer,
"content-language": [
string
],
"content-length": integer,
"content-security-policy": [
string
],
"content-security-policy-report-only": [
string
],
"cookie": [
string
],
"critical-ch": [
string
],
"date": string,
"date_epoch_utc": integer,
"expect-ct": [
string
],
"expires": string,
"expires_epoch_utc": integer,
"device-memory": integer,
"downlink": integer,
"dpr": integer,
"forwarded": [
string
],
"if-match": [
string
],
"if-modified-since": string,
"if-modified-since_epoch_utc": integer,
"if-none-match": [
string
],
"if-range": string,
"if-range_epoch_utc": integer,
"if-unmodified-since": string,
"if-unmodified-since_epoch_utc": integer,
"im": [
string
],
"keep-alive": [
string
],
"large-allocation": integer,
"last-modified": string,
"last-modified_epoch_utc": integer,
"link": [
string
],
"max-forwards": integer,
"memento-datetime": string,
"memento-datetime_epoch_utc": integer,
"permissions-policy": [
string
],
"permissions-policy-report-only": [
string
],
"pragma": [
string
],
"proxy-authenticate": [
string
],
"reporting-endpoints": [
string
],
"retry-after": string,
"retry-after_epoch_utc": integer,
"rtt": integer,
"sec-ch-ua": [
string
],
"sec-ch-ua-full-version-list": [
string
],
"server": [
string
],
"server-timing": [
string
],
"set-cookie": [
string
],
"timing-allow-origin": [
string
],
"trailer": [
string
],
"transfer-encoding": [
string
],
"upgrade": [
string
],
"upgrade-insecure-requests": integer,
"vary": [
string
],
"via": [
string
],
"warning": [
string
],
"www-authenticate": [
string
],
"x-cache-hits": [
integer
],
"x-content-duration": float
}
]
Examples:
$ curl --head www.example.com | jc --curl-head -p
[
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 241144,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:26:29 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:26:29 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2508)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707089189,
"expires_epoch_utc": 1707693989,
"last-modified_epoch_utc": 1571296706
}
]
$ curl --head www.example.com | jc --curl-head -p -r
[
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "225102",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:28:17 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:28:17 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2575)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.curl_head.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
```
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, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/curl_head.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/curl_head.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -100,4 +100,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/date.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/date.py)
This parser can be used with the `--slurp` command-line option.
Version 2.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -88,4 +88,8 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/datetime_iso.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/datetime_iso.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,107 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.debconf_show"></a>
# jc.parsers.debconf\_show
jc - JSON Convert `debconf-show` command output parser
Usage (cli):
$ debconf-show onlyoffice-documentserver | jc --debconf-show
or
$ jc debconf-show onlyoffice-documentserver
Usage (module):
import jc
result = jc.parse('debconf_show', debconf_show_command_output)
Schema:
[
{
"asked": boolean,
"packagename": string,
"name": string,
"value": string
}
]
Examples:
$ debconf-show onlyoffice-documentserver | jc --debconf-show -p
[
{
"asked": true,
"packagename": "onlyoffice",
"name": "jwt_secret",
"value": "aL8ei2iereuzee7cuJ6Cahjah1ixee2ah"
},
{
"asked": false,
"packagename": "onlyoffice",
"name": "db_pwd",
"value": "(password omitted)"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "rabbitmq_pwd",
"value": "(password omitted)"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "db_port",
"value": "5432"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "db_user",
"value": "onlyoffice"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "rabbitmq_proto",
"value": "amqp"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "cluster_mode",
"value": "false"
}
]
<a id="jc.parsers.debconf_show.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
```
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
Source: [`jc/parsers/debconf_show.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/debconf_show.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -120,4 +120,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Source: [`jc/parsers/df.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/df.py)
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -9,6 +9,7 @@ Options supported:
- `+noall +answer` options are supported in cases where only the answer
information is desired.
- `+axfr` option is supported on its own
- `+nsid` option is supported
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
local time of the system the parser is run on)
@@ -345,4 +346,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/dig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dig.py)
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: win32
Source: [`jc/parsers/dir.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dir.py)
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)

View File

@@ -148,4 +148,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/dmidecode.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dmidecode.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -154,4 +154,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/dpkg_l.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dpkg_l.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -114,4 +114,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/du.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/du.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

104
docs/parsers/efibootmgr.md Normal file
View File

@@ -0,0 +1,104 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.efibootmgr"></a>
# jc.parsers.efibootmgr
jc - JSON Convert `efibootmgr` command output parser
The `-v` option is also supported.
Usage (cli):
$ sudo efibootmgr | jc --efibootmgr
$ sudo efibootmgr -v | jc --efibootmgr
or
$ sudo jc efibootmgr
Usage (module):
import jc
result = jc.parse('efibootmgr', efibootmgr_command_output)
Schema:
{
"boot_current": string,
"timeout_seconds": integer,
"boot_order": [
string
],
mirrored_percentage_above_4g: float,
mirror_memory_below_4gb: boolean,
"boot_options": [
{
"boot_option_reference": string,
"display_name": string,
"uefi_device_path": string,
"boot_option_enabled": boolean
}
]
}
Examples:
$ sudo efibootmgr -v | jc --efibootmgr --p
{
"boot_current": "0002",
"timeout_seconds": 0,
"boot_order": [
"0002",
"0000",
"0001"
],
"mirrored_percentage_above_4g": 0.0,
"mirror_memory_below_4gb": false,
"boot_options": [
{
"boot_option_reference": "Boot0000",
"display_name": "WARNADO",
"uefi_device_path": "HD(1,GPT,05b9944c-1c60-492b-a510-7bbedccdc...",
"boot_option_enabled": true
},
{
"boot_option_reference": "Boot0001",
"display_name": "Embedded NIC 1 Port 1 Partition 1",
"uefi_device_path": "VenHw(3a191845-5f86-4e78-8fce-c4cff59f9daa)",
"boot_option_enabled": true
},
{
"boot_option_reference": "Boot0002",
"display_name": "opensuse-secureboot",
"uefi_device_path": "HD(1,GPT,c5d4f69d-6fc2-48c7-acee-af3f30336...",
"boot_option_enabled": true
}
]
}
<a id="jc.parsers.efibootmgr.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
```
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
Source: [`jc/parsers/efibootmgr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/efibootmgr.py)
Version 1.0 by Yaofei Zheng (zyf26256@gmail.com, Yaofei.Zheng@dell.com)

View File

@@ -64,4 +64,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/email_address.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/email_address.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -90,10 +90,12 @@ Parameters:
Returns:
Dictionary of raw structured data or
List of Dictionaries of processed structured data
Dictionary of raw structured data or (default)
List of Dictionaries of processed structured data (raw)
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/env.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/env.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -85,4 +85,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Source: [`jc/parsers/file.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/file.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

84
docs/parsers/find.md Normal file
View File

@@ -0,0 +1,84 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.find"></a>
# jc.parsers.find
jc - JSON Convert `find` command output parser
This parser returns a list of objects by default and a list of strings if
the `--raw` option is used.
Usage (cli):
$ find | jc --find
Usage (module):
import jc
result = jc.parse('find', find_command_output)
Schema:
[
{
"path": string,
"node": string,
"error": string
}
]
Examples:
$ find | jc --find -p
[
{
"path": "./directory"
"node": "filename"
},
{
"path": "./anotherdirectory"
"node": "anotherfile"
},
{
"path": null
"node": null
"error": "find: './inaccessible': Permission denied"
}
...
]
$ find | jc --find -p -r
[
"./templates/readme_template",
"./templates/manpage_template",
"./.github/workflows/pythonapp.yml",
...
]
<a id="jc.parsers.find.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
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 raw strings or
List of Dictionaries of processed structured data
### Parser Information
Compatibility: linux
Source: [`jc/parsers/find.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/find.py)
Version 1.0 by Solomon Leang (solomonleang@gmail.com)

View File

@@ -114,4 +114,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/findmnt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/findmnt.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -113,4 +113,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, freebsd
Source: [`jc/parsers/finger.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/finger.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -95,4 +95,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/free.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/free.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -108,4 +108,6 @@ Returns:
### Parser Information
Compatibility: linux, freebsd
Source: [`jc/parsers/fstab.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/fstab.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -172,4 +172,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/git_log.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_log.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -108,4 +108,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/git_log_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_log_s.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -89,4 +89,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/git_ls_remote.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_ls_remote.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -142,4 +142,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/gpg.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/gpg.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -132,4 +132,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/group.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/group.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -100,4 +100,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd
Source: [`jc/parsers/gshadow.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/gshadow.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -60,4 +60,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/hash.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hash.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -91,4 +91,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/hashsum.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hashsum.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -340,4 +340,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/hciconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hciconfig.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -87,4 +87,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/history.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/history.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

115
docs/parsers/host.md Normal file
View File

@@ -0,0 +1,115 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.host"></a>
# jc.parsers.host
jc - JSON Convert `host` command output parser
Supports parsing of the most commonly used RR types (A, AAAA, MX, TXT)
Usage (cli):
$ host google.com | jc --host
or
$ jc host google.com
Usage (module):
import jc
result = jc.parse('host', host_command_output)
Schema:
[
{
"hostname": string,
"address": [
string
],
"v6-address": [
string
],
"mail": [
string
]
}
]
[
{
"nameserver": string,
"zone": string,
"mname": string,
"rname": string,
"serial": integer,
"refresh": integer,
"retry": integer,
"expire": integer,
"minimum": integer
}
]
Examples:
$ host google.com | jc --host
[
{
"hostname": "google.com",
"address": [
"142.251.39.110"
],
"v6-address": [
"2a00:1450:400e:811::200e"
],
"mail": [
"smtp.google.com."
]
}
]
$ jc host -C sunet.se
[
{
"nameserver": "2001:6b0:7::2",
"zone": "sunet.se",
"mname": "sunic.sunet.se.",
"rname": "hostmaster.sunet.se.",
"serial": "2023090401",
"refresh": "28800",
"retry": "7200",
"expire": "604800",
"minimum": "300"
},
{
...
}
]
<a id="jc.parsers.host.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False)
```
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, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/host.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/host.py)
Version 1.0 by Pettai (pettai@sunet.se)

View File

@@ -97,4 +97,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/hosts.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hosts.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,336 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.http_headers"></a>
# jc.parsers.http\_headers
jc - JSON Convert HTTP headers parser
Converts HTTP request and response headers into a list of dictionaries.
Well-known headers are processed to allow multiple instances which are
aggregated into an array along with any comma-separated values. Integer,
float, and datetimes are converted where defined in the specifications.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
https://datatracker.ietf.org/doc/html/rfc2616
https://datatracker.ietf.org/doc/html/rfc3229
https://datatracker.ietf.org/doc/html/rfc7089
https://datatracker.ietf.org/doc/html/rfc7231
https://datatracker.ietf.org/doc/html/rfc5789
If you are converting HTTP headers from `curl` verbose output, use the
`curl-head` parser which will strip the `>` and `<` characters and remove
non-header lines that begin with `*`.
Usage (cli):
$ cat headers.txt | jc --http-headers
Usage (module):
import jc
result = jc.parse('http_headers', http_headers_output)
Schema:
[
{
"_type": string, # request or response
"_request_method": string,
"_request_uri": string,
"_request_version": string,
"_response_version": string,
"_response_status": integer,
"_response_reason": string or null,
"<header>": string,
# well-known headers:
"accept": [
string
],
"accept-ch": [
string
],
"accept-ch-lifetime": integer,
"accept-encoding": [
string
],
"accept-language": [
string
],
"accept-patch": [
string
],
"accept-post": [
string
],
"accept-ranges": [
string
],
"access-control-allow-headers": [
string
],
"access-control-allow-methods": [
string
],
"access-control-expose-headers": [
string
],
"access-control-max-age": integer,
"access-control-request-headers": [
string
],
"age": integer,
"allow": [
string
],
"alt-svc": [
string
],
"cache-control": [
string
],
"clear-site-data": [
string
],
"connection": [
string
],
"content-encoding": [
string
],
"content-dpr": integer,
"content-language": [
string
],
"content-length": integer,
"content-security-policy": [
string
],
"content-security-policy-report-only": [
string
],
"cookie": [
string
],
"critical-ch": [
string
],
"date": string,
"date_epoch_utc": integer,
"expect-ct": [
string
],
"expires": string,
"expires_epoch_utc": integer,
"device-memory": integer,
"downlink": integer,
"dpr": integer,
"forwarded": [
string
],
"if-match": [
string
],
"if-modified-since": string,
"if-modified-since_epoch_utc": integer,
"if-none-match": [
string
],
"if-range": string,
"if-range_epoch_utc": integer,
"if-unmodified-since": string,
"if-unmodified-since_epoch_utc": integer,
"im": [
string
],
"keep-alive": [
string
],
"large-allocation": integer,
"last-modified": string,
"last-modified_epoch_utc": integer,
"link": [
string
],
"max-forwards": integer,
"memento-datetime": string,
"memento-datetime_epoch_utc": integer,
"permissions-policy": [
string
],
"permissions-policy-report-only": [
string
],
"pragma": [
string
],
"proxy-authenticate": [
string
],
"reporting-endpoints": [
string
],
"retry-after": string,
"retry-after_epoch_utc": integer,
"rtt": integer,
"sec-ch-ua": [
string
],
"sec-ch-ua-full-version-list": [
string
],
"server": [
string
],
"server-timing": [
string
],
"set-cookie": [
string
],
"timing-allow-origin": [
string
],
"trailer": [
string
],
"transfer-encoding": [
string
],
"upgrade": [
string
],
"upgrade-insecure-requests": integer,
"vary": [
string
],
"via": [
string
],
"warning": [
string
],
"www-authenticate": [
string
],
"x-cache-hits": [
integer
],
"x-content-duration": float
}
]
Examples:
$ cat headers.txt | jc --http-headers -p
[
{
"_type": "request",
"_request_method": "HEAD",
"_request_uri": "/",
"_request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 140203,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707013507,
"expires_epoch_utc": 1707618307,
"last-modified_epoch_utc": 1571296706
}
]
$ cat headers.txt | jc --http-headers -p -r
[
{
"_type": "request",
"_request_method": "HEAD",
"_request_uri": "/",
"_request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "140203",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.http_headers.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
```
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, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/http_headers.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/http_headers.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -128,4 +128,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/id.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/id.py)
This parser can be used with the `--slurp` command-line option.
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -240,4 +240,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Source: [`jc/parsers/ifconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ifconfig.py)
Version 2.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -96,4 +96,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ini.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ini.py)
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -22,12 +22,12 @@ contained in lists/arrays.
Usage (cli):
$ cat foo.ini | jc --ini
$ cat foo.ini | jc --ini-dup
Usage (module):
import jc
result = jc.parse('ini', ini_file_output)
result = jc.parse('ini_dup', ini_file_output)
Schema:
@@ -67,7 +67,7 @@ Examples:
fruit = peach
color = green
$ cat example.ini | jc --ini -p
$ cat example.ini | jc --ini-dup -p
{
"foo": [
"fiz"
@@ -118,4 +118,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ini_dup.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ini_dup.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -182,4 +182,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iostat.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iostat.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -130,4 +130,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iostat_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iostat_s.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -552,4 +552,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ip_address.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ip_address.py)
This parser can be used with the `--slurp` command-line option.
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

76
docs/parsers/ip_route.md Normal file
View File

@@ -0,0 +1,76 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ip_route"></a>
# jc.parsers.ip\_route
jc - JSON Convert `ip route` command output parser
Usage (cli):
$ ip route | jc --ip-route
or
$ jc ip-route
Usage (module):
import jc
result = jc.parse('ip_route', ip_route_command_output)
Schema:
[
{
"ip": string,
"via": string,
"dev": string,
"metric": integer,
"proto": string,
"scope": string,
"src": string,
"via": string,
"status": string
}
]
Examples:
$ ip route | jc --ip-route -p
[
{
"ip": "10.0.2.0/24",
"dev": "enp0s3",
"proto": "kernel",
"scope": "link",
"src": "10.0.2.15",
"metric": 100
}
]
<a id="jc.parsers.ip_route.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
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 Json objects if data is processed and Raw data if raw = true.
### Parser Information
Compatibility: linux
Source: [`jc/parsers/ip_route.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ip_route.py)
Version 1.0 by Julian Jackson (jackson.julian55@yahoo.com)

View File

@@ -30,7 +30,7 @@ Schema:
"num" integer,
"pkts": integer,
"bytes": integer, # converted based on suffix
"target": string,
"target": string, # Null if blank
"prot": string,
"opt": string, # "--" = Null
"in": string,
@@ -186,4 +186,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/iptables.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iptables.py)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,37 +0,0 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iso_datetime"></a>
# jc.parsers.iso\_datetime
jc - JSON Convert ISO 8601 Datetime string parser
This parser has been renamed to datetime-iso (cli) or datetime_iso (module).
This parser will be removed in a future version, so please start using
the new parser name.
<a id="jc.parsers.iso_datetime.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
This parser is deprecated and calls datetime_iso. Please use datetime_iso
directly. This parser will be removed in the future.
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, aix, freebsd, darwin, win32, cygwin
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -144,4 +144,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iw_scan.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iw_scan.py)
Version 0.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -108,4 +108,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iwconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iwconfig.py)
Version 1.1 by Thomas Vincent (vrince@gmail.com)

View File

@@ -100,4 +100,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/jar_manifest.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jar_manifest.py)
Version 0.01 by Matt J (https://github.com/listuser)

View File

@@ -116,4 +116,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/jobs.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jobs.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -70,4 +70,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/jwt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jwt.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -79,4 +79,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/kv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/kv.py)
Version 2.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

91
docs/parsers/kv_dup.md Normal file
View File

@@ -0,0 +1,91 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.kv_dup"></a>
# jc.parsers.kv\_dup
jc - JSON Convert `Key/Value` with duplicate key file and string parser
Supports files containing simple key/value pairs and preserves duplicate
values. All values are contained in lists/arrays.
- Delimiter can be `=` or `:`. Missing values are supported.
- Comment prefix can be `#` or `;`. Comments must be on their own line.
- If multi-line values are used, each line will be a separate item in the
value list. Blank lines in multi-line values are not supported.
> Note: Values starting and ending with quotation marks will have the marks
> removed. If you would like to keep the quotation marks, use the `-r`
> command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.txt | jc --kv-dup
Usage (module):
import jc
result = jc.parse('kv_dup', kv_file_output)
Schema:
Key/Value document converted to a dictionary - see the python configparser
standard library documentation for more details.
{
"<key1>": [
string
],
"<key2>": [
string
]
}
Examples:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
# but can be preserved with the -r argument
occupation:"Engineer"
occupation = "Pilot"
$ cat keyvalue.txt | jc --kv-dup -p
{
"name": ["John Doe"],
"address": ["555 California Drive"],
"age": ["34"],
"occupation": ["Engineer", "Pilot"]
}
<a id="jc.parsers.kv_dup.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
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 representing a Key/Value pair document.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/kv_dup.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/kv_dup.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -5,7 +5,7 @@
jc - JSON Convert `last` and `lastb` command output parser
Supports `-w` and `-F` options.
Supports `-w`, `-F`, and `-x` options.
Calculated epoch time fields are naive (i.e. based on the local time of the
system the parser is run on) since there is no timezone information in the
@@ -127,4 +127,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/last.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/last.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -140,4 +140,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/ls.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ls.py)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -99,4 +99,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/ls_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ls_s.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

91
docs/parsers/lsattr.md Normal file
View File

@@ -0,0 +1,91 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsattr"></a>
# jc.parsers.lsattr
jc - JSON Convert `lsattr` command output parser
Usage (cli):
$ lsattr | jc --lsattr
or
$ jc lsattr
Usage (module):
import jc
result = jc.parse('lsattr', lsattr_command_output)
Schema:
Information from https://github.com/mirror/busybox/blob/2d4a3d9e6c1493a9520b907e07a41aca90cdfd94/e2fsprogs/e2fs_lib.c#L40
used to define field names
[
{
"file": string,
"compressed_file": Optional[boolean],
"compressed_dirty_file": Optional[boolean],
"compression_raw_access": Optional[boolean],
"secure_deletion": Optional[boolean],
"undelete": Optional[boolean],
"synchronous_updates": Optional[boolean],
"synchronous_directory_updates": Optional[boolean],
"immutable": Optional[boolean],
"append_only": Optional[boolean],
"no_dump": Optional[boolean],
"no_atime": Optional[boolean],
"compression_requested": Optional[boolean],
"encrypted": Optional[boolean],
"journaled_data": Optional[boolean],
"indexed_directory": Optional[boolean],
"no_tailmerging": Optional[boolean],
"top_of_directory_hierarchies": Optional[boolean],
"extents": Optional[boolean],
"no_cow": Optional[boolean],
"casefold": Optional[boolean],
"inline_data": Optional[boolean],
"project_hierarchy": Optional[boolean],
"verity": Optional[boolean],
}
]
Examples:
$ sudo lsattr /etc/passwd | jc --lsattr
[
{
"file": "/etc/passwd",
"extents": true
}
]
<a id="jc.parsers.lsattr.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
```
Main text parsing function
Parameters:
data: (string) text data to parse
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsattr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsattr.py)
Version 1.0 by Mark Rotner (rotner.mr@gmail.com)

View File

@@ -0,0 +1,63 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsb_release"></a>
# jc.parsers.lsb\_release
jc - JSON Convert `lsb_release` command parser
This parser is an alias to the Key/Value parser (`--kv`).
Usage (cli):
$ lsb_release -a | jc --lsb-release
or
$ jc lsb_release -a
Usage (module):
import jc
result = jc.parse('lsb_release', lsb_release_command_output)
Schema:
{
"<key>": string
}
Examples:
$ lsb_release -a | jc --lsb-release -p
{
"Distributor ID": "Ubuntu",
"Description": "Ubuntu 16.04.6 LTS",
"Release": "16.04",
"Codename": "xenial"
}
<a id="jc.parsers.lsb_release.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
```
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, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/lsb_release.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsb_release.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -297,4 +297,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsblk.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsblk.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -148,4 +148,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsmod.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsmod.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -142,4 +142,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/lsof.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsof.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -145,4 +145,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lspci.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lspci.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -330,4 +330,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsusb.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsusb.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -87,4 +87,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/m3u.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/m3u.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -249,4 +249,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mdadm.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mdadm.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -98,4 +98,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd, aix
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/mount.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mount.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -137,4 +137,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mpstat.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mpstat.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -125,4 +125,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mpstat_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mpstat_s.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -376,6 +376,8 @@ Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, freebsd
Compatibility: linux, darwin, freebsd, win32
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/netstat.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/netstat.py)
Version 1.15 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -168,4 +168,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/nmcli.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/nmcli.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,92 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.nsd_control"></a>
# jc.parsers.nsd\_control
jc - JSON Convert `nsd-control` command output parser
Usage (cli):
$ nsd-control | jc --nsd-control
or
$ jc nsd-control
Usage (module):
import jc
result = jc.parse('nsd_control', nsd_control_command_output)
Schema:
[
{
"version": string,
"verbosity": integer,
"ratelimit": integer
}
]
[
{
"zone": string
"status": {
"state": string,
"served-serial": string,
"commit-serial": string,
"wait": string
}
}
]
Examples:
$ nsd-control | jc --nsd-control status
[
{
"version": "4.6.2",
"verbosity": "2",
"ratelimit": "0"
}
]
$ nsd-control | jc --nsd-control zonestatus sunet.se
[
{
"zone": "sunet.se",
"status": {
"state": "ok",
"served-serial": "2023090704 since 2023-09-07T16:34:27",
"commit-serial": "2023090704 since 2023-09-07T16:34:27",
"wait": "28684 sec between attempts"
}
}
]
<a id="jc.parsers.nsd_control.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False)
```
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, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/nsd_control.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/nsd_control.py)
Version 1.1 by Pettai (pettai@sunet.se)

View File

@@ -229,4 +229,6 @@ Returns:
### Parser Information
Compatibility: linux, freebsd
Source: [`jc/parsers/ntpq.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ntpq.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -175,4 +175,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/openvpn.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/openvpn.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

Some files were not shown because too many files have changed in this diff Show More