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

70 lines
2.5 KiB
Markdown
Raw Normal View History

2020-07-30 16:20:24 -07:00
2019-11-11 18:30:46 -08:00
# jc
JC - JSON CLI output utility
* kellyjonbrazil@gmail.com
This package serializes the output of many standard unix command line tools to JSON format.
CLI Example:
$ ls -l /usr/bin | jc --ls -p
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
2019-11-12 14:15:22 -08:00
"links": 1,
2019-11-11 18:30:46 -08:00
"owner": "root",
"group": "root",
2019-11-12 14:15:22 -08:00
"size": 6,
2019-11-11 18:30:46 -08:00
"date": "Aug 15 10:53"
},
{
2019-11-12 14:15:22 -08:00
"filename": "ar",
2019-11-11 18:30:46 -08:00
"flags": "-rwxr-xr-x.",
2019-11-12 14:15:22 -08:00
"links": 1,
2019-11-11 18:30:46 -08:00
"owner": "root",
"group": "root",
2019-11-12 14:15:22 -08:00
"size": 62744,
"date": "Aug 8 16:14"
2019-11-11 18:30:46 -08:00
},
{
2019-11-12 14:15:22 -08:00
"filename": "arch",
2019-11-11 18:30:46 -08:00
"flags": "-rwxr-xr-x.",
2019-11-12 14:15:22 -08:00
"links": 1,
2019-11-11 18:30:46 -08:00
"owner": "root",
"group": "root",
2019-11-12 14:15:22 -08:00
"size": 33080,
2019-11-11 18:30:46 -08:00
"date": "Aug 19 23:25"
},
...
]
Module Example:
>>> import jc.parsers.ls
>>>
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
>>>
>>> jc.parsers.ls.parse(data)
2019-11-12 14:15:22 -08:00
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23648,
'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root',
'group': 'wheel', 'size': 30016, 'date': 'May 3 22:26'}, {'filename': 'cp', 'flags': '-rwxr-xr-x',
'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 29024, 'date': 'May 3 22:26'}, {'filename': 'csh',
'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 375824, 'date': 'May 3
22:26'}, {'filename': 'date', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel',
'size': 28608, 'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': 1, 'owner':
'root', 'group': 'wheel', 'size': 32000, 'date': 'May 3 22:26'}, {'filename': 'df', 'flags':
'-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23392, 'date': 'May 3 22:26'},
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 18128,
'date': 'May 3 22:26'}]
2019-11-11 18:30:46 -08:00