mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
fix env parser
This commit is contained in:
31
README.md
31
README.md
@ -122,32 +122,17 @@ $ df | jc --df -p
|
|||||||
### env
|
### env
|
||||||
```
|
```
|
||||||
$ env | jc --env -p
|
$ env | jc --env -p
|
||||||
[
|
|
||||||
{
|
|
||||||
"TERM": "xterm-256color"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"SHELL": "/bin/bash"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"USER": "root"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"PWD": "/bin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"LANG": "en_US.UTF-8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"HOME": "/root"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
|
"TERM": "xterm-256color",
|
||||||
|
"SHELL": "/bin/bash",
|
||||||
|
"USER": "root",
|
||||||
|
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
|
"PWD": "/root",
|
||||||
|
"LANG": "en_US.UTF-8",
|
||||||
|
"HOME": "/root",
|
||||||
|
"LOGNAME": "root",
|
||||||
"_": "/usr/bin/env"
|
"_": "/usr/bin/env"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
```
|
```
|
||||||
### ifconfig
|
### ifconfig
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
|
2019xxxx v1.0.1
|
||||||
|
- Fix env parser
|
||||||
|
|
||||||
20191023 v0.9.1
|
20191023 v0.9.1
|
||||||
- Add jobs parser
|
- Add jobs parser
|
||||||
- Add lsof parser
|
- Add lsof parser
|
||||||
|
@ -5,37 +5,23 @@ Usage:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
$ env | jc --env -p
|
$ env | jc --env -p
|
||||||
[
|
|
||||||
{
|
|
||||||
"TERM": "xterm-256color"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"SHELL": "/bin/bash"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"USER": "root"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"PWD": "/bin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"LANG": "en_US.UTF-8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"HOME": "/root"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
|
"TERM": "xterm-256color",
|
||||||
|
"SHELL": "/bin/bash",
|
||||||
|
"USER": "root",
|
||||||
|
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
|
"PWD": "/root",
|
||||||
|
"LANG": "en_US.UTF-8",
|
||||||
|
"HOME": "/root",
|
||||||
|
"LOGNAME": "root",
|
||||||
"_": "/usr/bin/env"
|
"_": "/usr/bin/env"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def parse(data):
|
def parse(data):
|
||||||
output = []
|
output = {}
|
||||||
|
|
||||||
linedata = data.splitlines()
|
linedata = data.splitlines()
|
||||||
|
|
||||||
@ -45,9 +31,7 @@ def parse(data):
|
|||||||
if cleandata:
|
if cleandata:
|
||||||
|
|
||||||
for entry in cleandata:
|
for entry in cleandata:
|
||||||
output_line = {}
|
|
||||||
parsed_line = entry.split('=', maxsplit=1)
|
parsed_line = entry.split('=', maxsplit=1)
|
||||||
output_line[parsed_line[0]] = parsed_line[1]
|
output[parsed_line[0]] = parsed_line[1]
|
||||||
output.append(output_line)
|
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
Reference in New Issue
Block a user