mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
doc update
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
jc changelog
|
||||
|
||||
20220118 v1.18.0
|
||||
- Add high-level parse API for built-in and plugin parsers
|
||||
|
||||
20220106 v1.17.7
|
||||
- Add stat command streaming parser tested on linux and macOS
|
||||
|
||||
|
10
README.md
10
README.md
@ -32,10 +32,10 @@ $ jc dig example.com | jq -r '.[].answer[].data'
|
||||
The `jc` parsers can also be used as python modules. In this case the output will be a python dictionary, or list of dictionaries, instead of JSON:
|
||||
```python
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||
>>> data = jc.parse('dig', cmd_output)
|
||||
>>>
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
|
||||
@ -290,9 +290,9 @@ Streaming parsers accept any iterable object and return a generator iterator obj
|
||||
|
||||
To use the generator object in your code, simply loop through it or use the [next()](https://docs.python.org/3/library/functions.html#next) builtin function:
|
||||
```python
|
||||
import jc.parsers.ls_s
|
||||
import jc
|
||||
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||
for item in result:
|
||||
print(item["filename"])
|
||||
```
|
||||
|
@ -57,8 +57,22 @@ CLI Example:
|
||||
|
||||
Module Example:
|
||||
|
||||
>>> import jc.parsers.dig
|
||||
>>> import subprocess
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parse('dig', cmd_output)
|
||||
>>>
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
|
||||
1, 'authority_num': 0, 'additional_num': 1, 'opt_pseudosection': {'edns': {'version': 0, 'flags': [], 'udp':
|
||||
4096}}, 'question': {'name': 'example.com.', 'class': 'IN', 'type': 'A'}, 'answer': [{'name': 'example.com.',
|
||||
'class': 'IN', 'type': 'A', 'ttl': 29658, 'data': '93.184.216.34'}], 'query_time': 52, 'server':
|
||||
'2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)', 'when': 'Fri Apr 16 16:13:00 PDT 2021', 'rcvd': 56,
|
||||
'when_epoch': 1618614780, 'when_epoch_utc': None}]
|
||||
|
||||
Alternatively, you can bypass the high-level API and call the parser modules directly:
|
||||
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
|
2
man/jc.1
2
man/jc.1
@ -1,4 +1,4 @@
|
||||
.TH jc 1 2022-01-14 1.17.7 "JSON CLI output utility"
|
||||
.TH jc 1 2022-01-18 1.18.0 "JSON CLI output utility"
|
||||
.SH NAME
|
||||
jc \- JSONifies the output of many CLI tools and file-types
|
||||
.SH SYNOPSIS
|
||||
|
@ -32,10 +32,10 @@ $ jc dig example.com | jq -r '.[].answer[].data'
|
||||
The `jc` parsers can also be used as python modules. In this case the output will be a python dictionary, or list of dictionaries, instead of JSON:
|
||||
```python
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||
>>> data = jc.parse('dig', cmd_output)
|
||||
>>>
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
|
||||
@ -206,9 +206,9 @@ Streaming parsers accept any iterable object and return a generator iterator obj
|
||||
|
||||
To use the generator object in your code, simply loop through it or use the [next()](https://docs.python.org/3/library/functions.html#next) builtin function:
|
||||
```python
|
||||
import jc.parsers.ls_s
|
||||
import jc
|
||||
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||
for item in result:
|
||||
print(item["filename"])
|
||||
```
|
||||
|
Reference in New Issue
Block a user