mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
history parser fixes
This commit is contained in:
@ -162,10 +162,10 @@ $ free | jc --free -p
|
|||||||
```
|
```
|
||||||
$ history | jc --history -p
|
$ history | jc --history -p
|
||||||
{
|
{
|
||||||
"118": "sleep 100",
|
"n118": "sleep 100",
|
||||||
"119": "ls /bin",
|
"n119": "ls /bin",
|
||||||
"120": "echo \"hello\"",
|
"n120": "echo \"hello\"",
|
||||||
"121": "docker images",
|
"n121": "docker images",
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -7,10 +7,10 @@ Example:
|
|||||||
|
|
||||||
$ history | jc --history -p
|
$ history | jc --history -p
|
||||||
{
|
{
|
||||||
"118": "sleep 100",
|
"n118": "sleep 100",
|
||||||
"119": "ls /bin",
|
"n119": "ls /bin",
|
||||||
"120": "echo \"hello\"",
|
"n120": "echo \"hello\"",
|
||||||
"121": "docker images",
|
"n121": "docker images",
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -26,7 +26,12 @@ def parse(data):
|
|||||||
|
|
||||||
if cleandata:
|
if cleandata:
|
||||||
for entry in cleandata:
|
for entry in cleandata:
|
||||||
parsed_line = entry.split(maxsplit=1)
|
try:
|
||||||
output[parsed_line[0]] = parsed_line[1]
|
parsed_line = entry.split(maxsplit=1)
|
||||||
|
# prepend a alpha character n to be more json compliant
|
||||||
|
output['n' + parsed_line[0]] = parsed_line[1]
|
||||||
|
except IndexError:
|
||||||
|
# need to catch indexerror in case there is weird input from prior commands
|
||||||
|
pass
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
Reference in New Issue
Block a user