1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

readme update

This commit is contained in:
Kelly Brazil
2019-10-21 13:47:22 -07:00
parent 5f88f7d8a0
commit be81b5e1ed

233
README.md
View File

@ -24,16 +24,21 @@ $ pip3 install jc
``` ```
## Usage ## Usage
```
jc [parser] [options]
```
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. The JSON output can be compact or pretty formatted. `jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. The JSON output can be compact or pretty formatted.
The first argument is required and identifies the command that is piping output to `jc` input. For example: Parsers:
- `--ls` enables the `ls` parser - `--ls` enables the `ls` parser
- `--ifconfig` enables the `ifconfig` parser - `--ifconfig` enables the `ifconfig` parser
- `--netstat` enables the `netstat` parser - `--netstat` enables the `netstat` parser
- `--ps` enables the `ps` parser - `--ps` enables the `ps` parser
- `--route` enables the `route` parser - `--route` enables the `route` parser
The second `-p` argument is optional and specifies whether to pretty format the JSON output. Options:
- `-p` specifies whether to pretty format the JSON output
## Examples ## Examples
### ls ### ls
@ -157,129 +162,115 @@ $ ifconfig | jc --ifconfig -p
### netstat ### netstat
``` ```
$ netstat -p | jc --netstat -p $ netstat -p | jc --netstat -p
{ [
"client": { {
"tcp": { "session_protocol": "tcp",
"ipv4": [ "network_protocol": "ipv4",
{ "local_address": "localhost.localdo",
"local_address": "localhost.localdo", "local_port": "34480",
"local_port": "34480", "foreign_address": "lb-192-30-255-113",
"foreign_address": "lb-192-30-255-113", "foreign_port": "https",
"foreign_port": "https", "state": "ESTABLISHED",
"state": "ESTABLISHED", "pid": 53550,
"pid": 53550, "program_name": "git-remote-ht",
"program_name": "git-remote-ht", "receive_q": 0,
"receive_q": 0, "send_q": 0
"send_q": 0 },
}, {
{ "session_protocol": "tcp",
"local_address": "localhost.localdo", "network_protocol": "ipv4",
"local_port": "34478", "local_address": "localhost.localdo",
"foreign_address": "lb-192-30-255-113", "local_port": "34478",
"foreign_port": "https", "foreign_address": "lb-192-30-255-113",
"state": "ESTABLISHED", "foreign_port": "https",
"pid": 53550, "state": "ESTABLISHED",
"program_name": "git-remote-ht", "pid": 53550,
"receive_q": 0, "program_name": "git-remote-ht",
"send_q": 0 "receive_q": 0,
} "send_q": 0
]
}
} }
} ]
``` ```
``` ```
$ netstat -lp | jc --netstat -p $ netstat -lpn | jc --netstat -p
{ [
"server": { {
"tcp": { "session_protocol": "tcp",
"ipv4": [ "network_protocol": "ipv4",
{ "local_address": "127.0.0.1",
"local_address": "localhost", "local_port": "42351",
"local_port": "smtp", "foreign_address": "0.0.0.0",
"foreign_address": "0.0.0.0", "foreign_port": "*",
"foreign_port": "*", "state": "LISTEN",
"state": "LISTEN", "pid": 1112,
"pid": 1594, "program_name": "containerd",
"program_name": "master", "receive_q": 0,
"receive_q": 0, "send_q": 0
"send_q": 0 },
}, {
{ "session_protocol": "tcp",
"local_address": "0.0.0.0", "network_protocol": "ipv4",
"local_port": "ssh", "local_address": "127.0.0.53",
"foreign_address": "0.0.0.0", "local_port": "53",
"foreign_port": "*", "foreign_address": "0.0.0.0",
"state": "LISTEN", "foreign_port": "*",
"pid": 21918, "state": "LISTEN",
"program_name": "sshd", "pid": 885,
"receive_q": 0, "program_name": "systemd-resolve",
"send_q": 0 "receive_q": 0,
} "send_q": 0
], },
"ipv6": [ {
{ "session_protocol": "tcp",
"local_address": "localhost", "network_protocol": "ipv4",
"local_port": "smtp", "local_address": "0.0.0.0",
"foreign_address": "[::]", "local_port": "22",
"foreign_port": "*", "foreign_address": "0.0.0.0",
"state": "LISTEN", "foreign_port": "*",
"pid": 1594, "state": "LISTEN",
"program_name": "master", "pid": 1127,
"receive_q": 0, "program_name": "sshd",
"send_q": 0 "receive_q": 0,
}, "send_q": 0
{ },
"local_address": "[::]", {
"local_port": "ssh", "session_protocol": "tcp",
"foreign_address": "[::]", "network_protocol": "ipv6",
"foreign_port": "*", "local_address": "::",
"state": "LISTEN", "local_port": "22",
"pid": 21918, "foreign_address": "::",
"program_name": "sshd", "foreign_port": "*",
"receive_q": 0, "state": "LISTEN",
"send_q": 0 "pid": 1127,
} "program_name": "sshd",
] "receive_q": 0,
}, "send_q": 0
"udp": { },
"ipv4": [ {
{ "session_protocol": "udp",
"local_address": "0.0.0.0", "network_protocol": "ipv4",
"local_port": "bootpc", "local_address": "127.0.0.53",
"foreign_address": "0.0.0.0", "local_port": "53",
"foreign_port": "*", "foreign_address": "0.0.0.0",
"pid": 13903, "foreign_port": "*",
"program_name": "dhclient", "pid": 885,
"receive_q": 0, "program_name": "systemd-resolve",
"send_q": 0 "receive_q": 0,
}, "send_q": 0
{ },
"local_address": "localhost", {
"local_port": "323", "session_protocol": "udp",
"foreign_address": "0.0.0.0", "network_protocol": "ipv4",
"foreign_port": "*", "local_address": "192.168.71.131",
"pid": 30926, "local_port": "68",
"program_name": "chronyd", "foreign_address": "0.0.0.0",
"receive_q": 0, "foreign_port": "*",
"send_q": 0 "pid": 867,
} "program_name": "systemd-network",
], "receive_q": 0,
"ipv6": [ "send_q": 0
{
"local_address": "localhost",
"local_port": "323",
"foreign_address": "[::]",
"foreign_port": "*",
"pid": 30926,
"program_name": "chronyd",
"receive_q": 0,
"send_q": 0
}
]
}
} }
} ]
``` ```
### ps ### ps
``` ```