mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
documentation updates
This commit is contained in:
33
README.md
33
README.md
@ -96,6 +96,13 @@ $ arp | jc --arp -p
|
|||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"address": "192.168.71.1",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:c0:00:08",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"address": "192.168.71.254",
|
"address": "192.168.71.254",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
@ -105,6 +112,32 @@ $ arp | jc --arp -p
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
```
|
||||||
|
$ arp -a | jc --arp -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "?",
|
||||||
|
"address": "192.168.71.1",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:c0:00:08",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "?",
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_gateway",
|
||||||
|
"address": "192.168.71.2",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
### df
|
### df
|
||||||
```
|
```
|
||||||
$ df | jc --df -p
|
$ df | jc --df -p
|
||||||
|
@ -14,6 +14,13 @@ $ arp | jc --arp -p
|
|||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"address": "192.168.71.1",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:c0:00:08",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"address": "192.168.71.254",
|
"address": "192.168.71.254",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
@ -22,6 +29,31 @@ $ arp | jc --arp -p
|
|||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "?",
|
||||||
|
"address": "192.168.71.1",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:c0:00:08",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "?",
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_gateway",
|
||||||
|
"address": "192.168.71.2",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -36,10 +68,27 @@ def parse(data):
|
|||||||
if cleandata[-1].find("Entries:") == 0:
|
if cleandata[-1].find("Entries:") == 0:
|
||||||
cleandata.pop(-1)
|
cleandata.pop(-1)
|
||||||
|
|
||||||
# fix header row to change Flags Mask to flags_mask
|
# detect if linux or bsd style was used
|
||||||
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
if cleandata[0].find('Address') == 0:
|
||||||
|
|
||||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
# fix header row to change Flags Mask to flags_mask
|
||||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||||
|
|
||||||
return [dict(zip(headers, r)) for r in raw_data]
|
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||||
|
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||||
|
|
||||||
|
return [dict(zip(headers, r)) for r in raw_data]
|
||||||
|
|
||||||
|
else:
|
||||||
|
output = []
|
||||||
|
for line in cleandata:
|
||||||
|
line = line.split()
|
||||||
|
output_line = {}
|
||||||
|
output_line['name'] = line[0]
|
||||||
|
output_line['address'] = line[1].lstrip('(').rstrip(')')
|
||||||
|
output_line['hwtype'] = line[4].lstrip('[').rstrip(']')
|
||||||
|
output_line['hwaddress'] = line[3]
|
||||||
|
output_line['iface'] = line[6]
|
||||||
|
output.append(output_line)
|
||||||
|
|
||||||
|
return output
|
||||||
|
Reference in New Issue
Block a user