diff --git a/README.md b/README.md index 5bc90011..e783610f 100755 --- a/README.md +++ b/README.md @@ -17,6 +17,20 @@ $ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)' "date": "Aug 14 19:41" } ``` +or using the alternative "magic" syntax: +``` +$ jc ls -l /usr/bin | jq '.[] | select(.size > 50000000)' +{ + "filename": "docker", + "flags": "-rwxr-xr-x", + "links": 1, + "owner": "root", + "group": "root", + "size": 68677120, + "date": "Aug 14 19:41" +} +``` + For more information on the motivations for this project, please see my blog post at https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/. The `jc` parsers can also be used as python modules. In this case the output will be a python dictionary instead of JSON: @@ -49,7 +63,7 @@ Two representations of the data are possible. The default representation uses a To access the raw, pre-processed JSON, use the `-r` cli option or the `raw=True` function parameter in `parse()`. -Schemas for each parser can be found in the `docs/parsers` folder. +Schemas for each parser can be found in the [`docs/parsers`](https://github.com/kellyjonbrazil/jc/tree/dev/docs/parsers) folder. ## Installation ``` @@ -57,48 +71,56 @@ $ pip3 install --upgrade jc ``` ## Usage +`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. ``` -jc PARSER [OPTIONS] +COMMAND | 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. +or +``` +COMMAND | jc [OPTIONS] PARSER +``` +Alternatively, the "magic" syntax can be used by prepending `jc` to the command to be converted. Options can be passed to `jc` immediately before the command is given. +``` +jc [OPTIONS] COMMAND +``` +The JSON output can be compact (default) or pretty formatted with the `-p` option. ### Parsers -- `--arp` enables the `arp` parser -- `--crontab` enables the `crontab` file parser +- `--arp` enables the `arp` command parser +- `--crontab` enables the `crontab` command and file parser - `--crontab-u` enables the `crontab` file parser with user support -- `--df` enables the `df` parser -- `--dig` enables the `dig` parser -- `--du` enables the `du` parser -- `--env` enables the `env` parser -- `--free` enables the `free` parser +- `--df` enables the `df` command parser +- `--dig` enables the `dig` command parser +- `--du` enables the `du` command parser +- `--env` enables the `env` command parser +- `--free` enables the `free` command parser - `--fstab` enables the `/etc/fstab` file parser -- `--history` enables the `history` parser +- `--history` enables the `history` command parser - `--hosts` enables the `/etc/hosts` file parser -- `--id` enables the `id` parser -- `--ifconfig` enables the `ifconfig` parser +- `--id` enables the `id` command parser +- `--ifconfig` enables the `ifconfig` command parser - `--ini` enables the `INI` file parser -- `--iptables` enables the `iptables` parser -- `--jobs` enables the `jobs` parser -- `--ls` enables the `ls` parser -- `--lsblk` enables the `lsblk` parser -- `--lsmod` enables the `lsmod` parser -- `--lsof` enables the `lsof` parser -- `--mount` enables the `mount` parser -- `--netstat` enables the `netstat` parser -- `--pip-list` enables the `pip list` parser -- `--pip-show` enables the `pip show` parser -- `--ps` enables the `ps` parser -- `--route` enables the `route` parser -- `--ss` enables the `ss` parser -- `--stat` enables the `stat` parser -- `--systemctl` enables the `systemctl` parser -- `--systemctl-lj` enables the `systemctl list-jobs` parser -- `--systemctl-ls` enables the `systemctl list-sockets` parser -- `--systemctl-luf` enables the `systemctl list-unit-files` parser -- `--uname` enables the `uname -a` parser -- `--uptime` enables the `uptime` parser -- `--w` enables the `w` parser +- `--iptables` enables the `iptables` command parser +- `--jobs` enables the `jobs` command parser +- `--ls` enables the `ls` command parser +- `--lsblk` enables the `lsblk` command parser +- `--lsmod` enables the `lsmod` command parser +- `--lsof` enables the `lsof` command parser +- `--mount` enables the `mount` command parser +- `--netstat` enables the `netstat` command parser +- `--pip-list` enables the `pip list` command parser +- `--pip-show` enables the `pip show` command parser +- `--ps` enables the `ps` command parser +- `--route` enables the `route` command parser +- `--ss` enables the `ss` command parser +- `--stat` enables the `stat` command parser +- `--systemctl` enables the `systemctl` command parser +- `--systemctl-lj` enables the `systemctl list-jobs` command parser +- `--systemctl-ls` enables the `systemctl list-sockets` command parser +- `--systemctl-luf` enables the `systemctl list-unit-files` command parser +- `--uname` enables the `uname -a` command parser +- `--uptime` enables the `uptime` command parser +- `--w` enables the `w` command parser - `--xml` enables the `XML` file parser - `--yaml` enables the `YAML` file parser @@ -112,7 +134,7 @@ jc PARSER [OPTIONS] ## Examples ### arp ``` -$ arp | jc --arp -p +$ arp | jc --arp -p # or: jc -p arp [ { "address": "gateway", @@ -138,7 +160,7 @@ $ arp | jc --arp -p ] ``` ``` -$ arp -a | jc --arp -p +$ arp -a | jc --arp -p # or: jc -p arp -a [ { "name": null, @@ -165,7 +187,7 @@ $ arp -a | jc --arp -p ``` ### crontab ``` -$ cat /etc/crontab | jc --crontab -p +$ cat /etc/crontab | jc --crontab -p # or: jc -p crontab -l { "variables": [ { @@ -312,7 +334,7 @@ $ cat /etc/crontab | jc --crontab-u -p ``` ### df ``` -$ df | jc --df -p +$ df | jc --df -p # or: jc -p df [ { "filesystem": "devtmpfs", @@ -335,7 +357,7 @@ $ df | jc --df -p ``` ### dig ``` -$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p +$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p # or: jc -p dig cnn.com www.cnn.com @205.251.194.64 [ { "id": 5509, @@ -455,7 +477,7 @@ $ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p ] ``` ``` -$ dig -x 1.1.1.1 | jc --dig -p +$ dig -x 1.1.1.1 | jc --dig -p # or: jc -p dig -x 1.1.1.1 [ { "id": 50324, @@ -493,7 +515,7 @@ $ dig -x 1.1.1.1 | jc --dig -p ``` ### du ``` -$ du /usr | jc --du -p +$ du /usr | jc --du -p # or: jc -p du /usr [ { "size": 104608, @@ -524,7 +546,7 @@ $ du /usr | jc --du -p ``` ### env ``` -$ env | jc --env -p +$ env | jc --env -p # or: jc -p env [ { "name": "XDG_SESSION_ID", @@ -551,7 +573,7 @@ $ env | jc --env -p ``` ### free ``` -$ free | jc --free -p +$ free | jc --free -p # or: jc -p free [ { "type": "Mem", @@ -602,7 +624,7 @@ $ cat /etc/fstab | jc --fstab -p ``` ### history ``` -$ history | jc --history -p +$ history | jc --history -p # or: jc -p history [ { "line": 118, @@ -674,7 +696,7 @@ $ cat /etc/hosts | jc --hosts -p ``` ### id ``` -$ id | jc --id -p +$ id | jc --id -p # or: jc -p id { "uid": { "id": 1000, @@ -704,7 +726,7 @@ $ id | jc --id -p ``` ### ifconfig ``` -$ ifconfig | jc --ifconfig -p +$ ifconfig | jc --ifconfig -p # or: jc -p ifconfig [ { "name": "ens33", @@ -809,7 +831,7 @@ $ cat example.ini | jc --ini -p ``` ### iptables ``` -$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p +$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p # or: sudo jc -p iptables --line-numbers -v -L -t nat [ { "chain": "PREROUTING", @@ -870,7 +892,7 @@ $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p ``` ### jobs ``` -$ jobs -l | jc --jobs -p +$ jobs -l | jc --jobs -p # or: jc -p jobs [ { "job_number": 1, @@ -902,7 +924,7 @@ $ jobs -l | jc --jobs -p ``` ### ls ``` -$ ls -l /usr/bin | jc --ls -p +$ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin [ { "filename": "apropos", @@ -937,7 +959,7 @@ $ ls -l /usr/bin | jc --ls -p ``` ### lsblk ``` -$ lsblk | jc --lsblk -p +$ lsblk | jc --lsblk -p # or: jc -p lsblk [ { "name": "sda", @@ -962,7 +984,7 @@ $ lsblk | jc --lsblk -p ``` ### lsmod ``` -$ lsmod | jc --lsmod -p +$ lsmod | jc --lsmod -p # or: jc -p lsmod [ ... { @@ -1009,7 +1031,7 @@ $ lsmod | jc --lsmod -p ``` ### lsof ``` -$ sudo lsof | jc --lsof -p +$ sudo lsof | jc --lsof -p # or: sudo jc -p lsof [ { "command": "systemd", @@ -1052,7 +1074,7 @@ $ sudo lsof | jc --lsof -p ``` ### mount ``` -$ mount | jc --mount -p +$ mount | jc --mount -p # or: jc -p mount [ { "filesystem": "sysfs", @@ -1096,7 +1118,7 @@ $ mount | jc --mount -p ``` ### netstat ``` -$ sudo netstat -apee | jc --netstat -p +$ sudo netstat -apee | jc --netstat -p # or: sudo jc -p netstat -apee [ { "proto": "tcp", @@ -1248,7 +1270,7 @@ $ sudo netstat -apee | jc --netstat -p ``` ### pip list ``` -$ pip list | jc --pip-list -p +$ pip list | jc --pip-list -p # or: jc -p pip list # or: jc -p pip3 list [ { "package": "ansible", @@ -1268,7 +1290,7 @@ $ pip list | jc --pip-list -p ``` ### pip show ``` -$ pip show wrapt wheel | jc --pip-show -p +$ pip show wrapt wheel | jc --pip-show -p # or: jc -p pip show wrapt wheel # or: jc -p pip3 show wrapt wheel [ { "name": "wrapt", @@ -1298,7 +1320,7 @@ $ pip show wrapt wheel | jc --pip-show -p ``` ### ps ``` -$ ps -ef | jc --ps -p +$ ps -ef | jc --ps -p # or: jc -p ps -ef [ { "uid": "root", @@ -1334,7 +1356,7 @@ $ ps -ef | jc --ps -p ] ``` ``` -$ ps axu | jc --ps -p +$ ps axu | jc --ps -p # or: jc -p ps axu [ { "user": "root", @@ -1380,7 +1402,7 @@ $ ps axu | jc --ps -p ``` ### route ``` -$ route -ee | jc --route -p +$ route -ee | jc --route -p # or: jc -p route -ee [ { "destination": "default", @@ -1425,7 +1447,7 @@ $ route -ee | jc --route -p ``` ### ss ``` -$ sudo ss -a | jc --ss -p +$ sudo ss -a | jc --ss -p # or: sudo jc -p ss -a [ { "netid": "nl", @@ -1544,7 +1566,7 @@ $ sudo ss -a | jc --ss -p ``` ### stat ``` -$ stat /bin/* | jc --stat -p +$ stat /bin/* | jc --stat -p # or: jc -p stat /bin/* [ { "file": "/bin/bash", @@ -1591,7 +1613,7 @@ $ stat /bin/* | jc --stat -p ``` ### systemctl ``` -$ systemctl -a | jc --systemctl -p +$ systemctl -a | jc --systemctl -p # or: jc -p systemctl -a [ { "unit": "proc-sys-fs-binfmt_misc.automount", @@ -1619,7 +1641,7 @@ $ systemctl -a | jc --systemctl -p ``` ### systemctl list-jobs ``` -$ systemctl list-jobs| jc --systemctl-lj -p +$ systemctl list-jobs | jc --systemctl-lj -p # or: jc -p systemctl list-jobs [ { "job": 3543, @@ -1643,7 +1665,7 @@ $ systemctl list-jobs| jc --systemctl-lj -p ``` ### systemctl list-sockets ``` -$ systemctl list-sockets | jc --systemctl-ls -p +$ systemctl list-sockets | jc --systemctl-ls -p # or: jc -p systemctl list-sockets [ { "listen": "/dev/log", @@ -1665,7 +1687,7 @@ $ systemctl list-sockets | jc --systemctl-ls -p ``` ### systemctl list-unit-files ``` -$ systemctl list-unit-files | jc --systemctl-luf -p +$ systemctl list-unit-files | jc --systemctl-luf -p # or: jc -p systemctl list-unit-files [ { "unit_file": "proc-sys-fs-binfmt_misc.automount", @@ -1684,7 +1706,7 @@ $ systemctl list-unit-files | jc --systemctl-luf -p ``` ### uname -a ``` -$ uname -a | jc --uname -p +$ uname -a | jc --uname -p # or: jc -p uname -a { "kernel_name": "Linux", "node_name": "user-ubuntu", @@ -1698,7 +1720,7 @@ $ uname -a | jc --uname -p ``` ### uptime ``` -$ uptime | jc --uptime -p +$ uptime | jc --uptime -p # or: jc -p uptime { "time": "11:30:44", "uptime": "1 day, 21:17", @@ -1710,7 +1732,7 @@ $ uptime | jc --uptime -p ``` ### w ``` -$ w | jc --w -p +$ w | jc --w -p # or: jc -p w [ { "user": "root", @@ -1792,7 +1814,7 @@ $ cat cd_catalog.xml | jc --xml -p ``` ### YAML files ``` -$ cat istio-mtls-permissive.yaml +$ cat istio.yaml apiVersion: "authentication.istio.io/v1alpha1" kind: "Policy" metadata: @@ -1813,7 +1835,7 @@ spec: tls: mode: ISTIO_MUTUAL -$ cat istio-mtls-permissive.yaml | jc --yaml -p +$ cat istio.yaml | jc --yaml -p [ { "apiVersion": "authentication.istio.io/v1alpha1", diff --git a/changelog.txt b/changelog.txt index 945e2c71..da8ab063 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,11 @@ jc changelog +20200211 v1.7.3 +- Add alternative 'magic' syntax: e.g. `jc ls -al` +- Options can now be condensed (e.g. -prq is equivalant to -p -r -q) + 20200208 v1.7.2 -- Include test fixtures in wheel +- Include test fixtures in wheel and sdist 20200205 v1.7.1 - Add YAML file parser diff --git a/docs/parsers/crontab.md b/docs/parsers/crontab.md index 98eb08e4..c6d63870 100644 --- a/docs/parsers/crontab.md +++ b/docs/parsers/crontab.md @@ -1,9 +1,9 @@ # jc.parsers.crontab -jc - JSON CLI output utility crontab file Parser +jc - JSON CLI output utility crontab command and file Parser Usage: - specify --crontab as the first argument if the piped input is coming from a crontab file + specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file Compatibility: @@ -11,7 +11,7 @@ Compatibility: Examples: - $ cat /etc/crontab | jc --crontab -p + $ crontab -l | jc --crontab -p { "variables": [ { diff --git a/jc/cli.py b/jc/cli.py index 15f3774a..73024747 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -3,6 +3,8 @@ JC cli module """ import sys +import os +import shlex import importlib import textwrap import signal @@ -11,7 +13,7 @@ import jc.utils class info(): - version = '1.7.2' + version = '1.7.3' description = 'jc cli output JSON conversion tool' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -61,6 +63,7 @@ parsers = [ def ctrlc(signum, frame): + """exit with error on SIGINT""" sys.exit(1) @@ -80,12 +83,13 @@ def parser_mod_shortname(parser): def parser_module(parser): - """import the module just in time and present the module object""" + """import the module just in time and return the module object""" importlib.import_module('jc.parsers.' + parser_mod_shortname(parser)) return getattr(jc.parsers, parser_mod_shortname(parser)) def parsers_text(indent=0, pad=0): + """return the argument and description information from each parser""" ptext = '' for parser in parsers: parser_arg = parser_argument(parser) @@ -103,6 +107,7 @@ def parsers_text(indent=0, pad=0): def about_jc(): + """return jc info and the contents of each parser.info as a dictionary""" parser_list = [] for parser in parsers: @@ -132,12 +137,21 @@ def about_jc(): def helptext(message): + """return the help text with the list of parsers""" parsers_string = parsers_text(indent=12, pad=17) helptext_string = f''' jc: {message} - Usage: jc PARSER [OPTIONS] + Usage: COMMAND | jc PARSER [OPTIONS] + + or + + COMMAND | jc [OPTIONS] PARSER + + or magic syntax: + + jc [OPTIONS] COMMAND Parsers: {parsers_string} @@ -150,6 +164,10 @@ def helptext(message): Example: ls -al | jc --ls -p + + or using the magic syntax: + + jc -p ls -al ''' print(textwrap.dedent(helptext_string), file=sys.stderr) @@ -161,28 +179,102 @@ def json_out(data, pretty=False): print(json.dumps(data)) +def magic(): + """Parse with magic syntax: jc -p ls -al""" + if len(sys.argv) > 1 and not sys.argv[1].startswith('--'): + parser_info = about_jc()['parsers'] + # correctly parse escape characters and spaces with shlex + args_given = " ".join(map(shlex.quote, sys.argv[1:])).split() + options = [] + found_parser = None + + # find the options + if args_given[0].startswith('-'): + p = 0 + for i, arg in list(enumerate(args_given)): + # parser found - use standard syntax + if arg.startswith('--'): + return + # option found - populate option list + elif arg.startswith('-'): + options.append(args_given.pop(i - p)[1:]) + p = p + 1 + # command found if iterator didn't already stop - stop iterating + else: + break + + # find the command and parser + for parser in parser_info: + if 'magic_commands' in parser: + # first pass for two word commands: e.g. 'pip list' + for magic_command in parser['magic_commands']: + try: + if ' '.join(args_given[0:2]) == magic_command: + found_parser = parser['argument'] + break + # No command found - go to next loop (for cases like 'jc -a') + except Exception: + break + + # second pass for one word commands: e.g. 'ls' + if not found_parser: + for magic_command in parser['magic_commands']: + try: + if args_given[0] == magic_command: + found_parser = parser['argument'] + break + # No command found - use standard syntax (for cases like 'jc -a') + except Exception: + return + + # construct a new command line using the standard syntax: COMMAND | jc --PARSER -OPTIONS + run_command = ' '.join(args_given) + if found_parser: + if options: + cmd_options = '-' + ''.join(options) + else: + cmd_options = '' + whole_command = ' '.join([run_command, '|', 'jc', found_parser, cmd_options]) + + os.system(whole_command) + exit() + else: + helptext(f'parser not found for "{run_command}"') + sys.exit(1) + + def main(): + # break on ctrl-c keyboard interrupt signal.signal(signal.SIGINT, ctrlc) + # try magic syntax first: e.g. jc -p ls -al + magic() + + options = [] debug = False pretty = False quiet = False raw = False # options - if '-d' in sys.argv: + for opt in sys.argv: + if opt.startswith('-') and not opt.startswith('--'): + for flag in opt[1:]: + options.append(flag) + + if 'd' in options: debug = True - if '-p' in sys.argv: + if 'p' in options: pretty = True - if '-q' in sys.argv: + if 'q' in options: quiet = True - if '-r' in sys.argv: + if 'r' in options: raw = True - if '-a' in sys.argv: + if 'a' in options: json_out(about_jc(), pretty=pretty) exit() @@ -215,7 +307,7 @@ def main(): result = parser.parse(data, raw=raw, quiet=quiet) found = True break - except: + except Exception: jc.utils.error_message(f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.') sys.exit(1) diff --git a/jc/parsers/arp.py b/jc/parsers/arp.py index 87960000..1d8e9d92 100644 --- a/jc/parsers/arp.py +++ b/jc/parsers/arp.py @@ -92,12 +92,13 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'arp parser' + description = 'arp command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'aix', 'freebsd', 'darwin'] + magic_commands = ['arp'] __version__ = info.version diff --git a/jc/parsers/crontab.py b/jc/parsers/crontab.py index 4336b0ef..f656cf40 100644 --- a/jc/parsers/crontab.py +++ b/jc/parsers/crontab.py @@ -1,8 +1,8 @@ -"""jc - JSON CLI output utility crontab file Parser +"""jc - JSON CLI output utility crontab command and file Parser Usage: - specify --crontab as the first argument if the piped input is coming from a crontab file + specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file Compatibility: @@ -10,7 +10,7 @@ Compatibility: Examples: - $ cat /etc/crontab | jc --crontab -p + $ crontab -l | jc --crontab -p { "variables": [ { @@ -133,13 +133,14 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'crontab file parser' + description = 'crontab command and file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # details = 'enter any other details here' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'aix', 'freebsd'] + magic_commands = ['crontab'] __version__ = info.version diff --git a/jc/parsers/df.py b/jc/parsers/df.py index 379b3cc4..817f0a21 100644 --- a/jc/parsers/df.py +++ b/jc/parsers/df.py @@ -74,12 +74,13 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'df parser' + description = 'df command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin'] + magic_commands = ['df'] __version__ = info.version diff --git a/jc/parsers/dig.py b/jc/parsers/dig.py index b381483e..6966942d 100644 --- a/jc/parsers/dig.py +++ b/jc/parsers/dig.py @@ -325,12 +325,13 @@ import jc.utils class info(): version = '1.0' - description = 'dig parser' + description = 'dig command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'aix', 'freebsd', 'darwin'] + magic_commands = ['dig'] __version__ = info.version diff --git a/jc/parsers/du.py b/jc/parsers/du.py index c21eec8e..c0026558 100644 --- a/jc/parsers/du.py +++ b/jc/parsers/du.py @@ -74,13 +74,14 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'du parser' + description = 'du command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # details = 'enter any other details here' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'aix', 'freebsd'] + magic_commands = ['du'] __version__ = info.version diff --git a/jc/parsers/env.py b/jc/parsers/env.py index 86931c2e..d95ed003 100644 --- a/jc/parsers/env.py +++ b/jc/parsers/env.py @@ -53,12 +53,13 @@ import jc.utils class info(): version = '1.1' - description = 'env parser' + description = 'env command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + magic_commands = ['env'] __version__ = info.version diff --git a/jc/parsers/foo.py b/jc/parsers/foo.py index 983fe6d8..ffb80951 100644 --- a/jc/parsers/foo.py +++ b/jc/parsers/foo.py @@ -21,13 +21,14 @@ import jc.utils class info(): version = '1.0' - description = 'foo parser' + description = 'foo command parser' author = 'John Doe' author_email = 'johndoe@gmail.com' # details = 'enter any other details here' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + magic_commands = ['foo'] __version__ = info.version diff --git a/jc/parsers/free.py b/jc/parsers/free.py index 5deeb802..aaf119ec 100644 --- a/jc/parsers/free.py +++ b/jc/parsers/free.py @@ -54,12 +54,13 @@ import jc.parsers.universal class info(): version = '1.0' - description = 'free parser' + description = 'free command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['free'] __version__ = info.version diff --git a/jc/parsers/fstab.py b/jc/parsers/fstab.py index f8c79f2f..430378d0 100644 --- a/jc/parsers/fstab.py +++ b/jc/parsers/fstab.py @@ -71,7 +71,7 @@ import jc.utils class info(): version = '1.0' - description = '/etc/fstab file parser' + description = 'fstab file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' diff --git a/jc/parsers/history.py b/jc/parsers/history.py index 09950578..4f1b62b4 100644 --- a/jc/parsers/history.py +++ b/jc/parsers/history.py @@ -45,12 +45,13 @@ import jc class info(): version = '1.1' - description = 'history parser' + description = 'history command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['history'] __version__ = info.version diff --git a/jc/parsers/id.py b/jc/parsers/id.py index 42b7ff7c..c19021c6 100644 --- a/jc/parsers/id.py +++ b/jc/parsers/id.py @@ -71,13 +71,14 @@ import jc.utils class info(): version = '1.0' - description = 'id parser' + description = 'id command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # details = 'enter any other details here' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'aix', 'freebsd'] + magic_commands = ['id'] __version__ = info.version diff --git a/jc/parsers/ifconfig.py b/jc/parsers/ifconfig.py index 633050ff..7c4df2ed 100644 --- a/jc/parsers/ifconfig.py +++ b/jc/parsers/ifconfig.py @@ -147,13 +147,14 @@ from ifconfigparser import IfconfigParser class info(): version = '1.5' - description = 'ifconfig parser' + description = 'ifconfig command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Using ifconfig-parser package from https://github.com/KnightWhoSayNi/ifconfig-parser' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'aix', 'freebsd', 'darwin'] + magic_commands = ['ifconfig'] __version__ = info.version diff --git a/jc/parsers/iptables.py b/jc/parsers/iptables.py index 380ceb63..9a75fd78 100644 --- a/jc/parsers/iptables.py +++ b/jc/parsers/iptables.py @@ -135,12 +135,13 @@ import jc.utils class info(): version = '1.1' - description = 'iptables parser' + description = 'iptables command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['iptables'] __version__ = info.version diff --git a/jc/parsers/jobs.py b/jc/parsers/jobs.py index 27760553..c5c5f0b8 100644 --- a/jc/parsers/jobs.py +++ b/jc/parsers/jobs.py @@ -78,12 +78,13 @@ import jc.utils class info(): version = '1.0' - description = 'jobs parser' + description = 'jobs command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['jobs'] __version__ = info.version diff --git a/jc/parsers/ls.py b/jc/parsers/ls.py index 9b5485bf..e3500428 100644 --- a/jc/parsers/ls.py +++ b/jc/parsers/ls.py @@ -145,12 +145,13 @@ import jc.utils class info(): version = '1.0' - description = 'ls parser' + description = 'ls command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['ls'] __version__ = info.version diff --git a/jc/parsers/lsblk.py b/jc/parsers/lsblk.py index 38bb6508..49544d51 100644 --- a/jc/parsers/lsblk.py +++ b/jc/parsers/lsblk.py @@ -217,12 +217,13 @@ import jc.parsers.universal class info(): version = '1.3' - description = 'lsblk parser' + description = 'lsblk command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['lsblk'] __version__ = info.version diff --git a/jc/parsers/lsmod.py b/jc/parsers/lsmod.py index 9cbf0f62..6b8cf40a 100644 --- a/jc/parsers/lsmod.py +++ b/jc/parsers/lsmod.py @@ -108,12 +108,13 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'lsmod parser' + description = 'lsmod command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['lsmod'] __version__ = info.version diff --git a/jc/parsers/lsof.py b/jc/parsers/lsof.py index 97a92fc3..6557ad9f 100644 --- a/jc/parsers/lsof.py +++ b/jc/parsers/lsof.py @@ -98,12 +98,13 @@ import jc.parsers.universal class info(): version = '1.0' - description = 'lsof parser' + description = 'lsof command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['lsof'] __version__ = info.version diff --git a/jc/parsers/mount.py b/jc/parsers/mount.py index e265b10e..0fcdb690 100644 --- a/jc/parsers/mount.py +++ b/jc/parsers/mount.py @@ -57,12 +57,13 @@ import jc.utils class info(): version = '1.1' - description = 'mount parser' + description = 'mount command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin'] + magic_commands = ['mount'] __version__ = info.version diff --git a/jc/parsers/netstat.py b/jc/parsers/netstat.py index a7bc00f8..a31531c5 100644 --- a/jc/parsers/netstat.py +++ b/jc/parsers/netstat.py @@ -314,12 +314,13 @@ import jc.utils class info(): version = '1.2' - description = 'netstat parser' + description = 'netstat command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['netstat'] __version__ = info.version diff --git a/jc/parsers/pip_list.py b/jc/parsers/pip_list.py index e7d1e96a..5bcd5160 100644 --- a/jc/parsers/pip_list.py +++ b/jc/parsers/pip_list.py @@ -33,12 +33,13 @@ import jc.parsers.universal class info(): version = '1.0' - description = 'pip list parser' + description = 'pip list command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + magic_commands = ['pip list', 'pip3 list'] __version__ = info.version diff --git a/jc/parsers/pip_show.py b/jc/parsers/pip_show.py index 6d085832..185e0528 100644 --- a/jc/parsers/pip_show.py +++ b/jc/parsers/pip_show.py @@ -43,12 +43,13 @@ import jc.utils class info(): version = '1.0' - description = 'pip show parser' + description = 'pip show command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] + magic_commands = ['pip show', 'pip3 show'] __version__ = info.version diff --git a/jc/parsers/ps.py b/jc/parsers/ps.py index 05c8bfe7..1b91275a 100644 --- a/jc/parsers/ps.py +++ b/jc/parsers/ps.py @@ -178,12 +178,13 @@ import jc.parsers.universal class info(): version = '1.1' - description = 'ps parser' + description = 'ps command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['ps'] __version__ = info.version diff --git a/jc/parsers/route.py b/jc/parsers/route.py index 7921edd7..668ea354 100644 --- a/jc/parsers/route.py +++ b/jc/parsers/route.py @@ -102,12 +102,13 @@ import jc.parsers.universal class info(): version = '1.0' - description = 'route parser' + description = 'route command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['route'] __version__ = info.version diff --git a/jc/parsers/ss.py b/jc/parsers/ss.py index 05a6e5df..13ac4166 100644 --- a/jc/parsers/ss.py +++ b/jc/parsers/ss.py @@ -252,12 +252,13 @@ import jc.utils class info(): version = '1.0' - description = 'ss parser' + description = 'ss command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['ss'] __version__ = info.version diff --git a/jc/parsers/stat.py b/jc/parsers/stat.py index 72283c3a..ecf89f48 100644 --- a/jc/parsers/stat.py +++ b/jc/parsers/stat.py @@ -105,12 +105,13 @@ import jc.utils class info(): version = '1.0' - description = 'stat parser' + description = 'stat command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['stat'] __version__ = info.version diff --git a/jc/parsers/systemctl.py b/jc/parsers/systemctl.py index d9cec6dd..d70fe63f 100644 --- a/jc/parsers/systemctl.py +++ b/jc/parsers/systemctl.py @@ -41,12 +41,13 @@ import jc.utils class info(): version = '1.0' - description = 'systemctl parser' + description = 'systemctl command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['systemctl'] __version__ = info.version diff --git a/jc/parsers/systemctl_lj.py b/jc/parsers/systemctl_lj.py index fa2c1a68..0ca69dbf 100644 --- a/jc/parsers/systemctl_lj.py +++ b/jc/parsers/systemctl_lj.py @@ -60,12 +60,13 @@ import jc.utils class info(): version = '1.0' - description = 'systemctl list-jobs parser' + description = 'systemctl list-jobs command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['systemctl list-jobs'] __version__ = info.version diff --git a/jc/parsers/systemctl_ls.py b/jc/parsers/systemctl_ls.py index ce01b91a..bbc2c27d 100644 --- a/jc/parsers/systemctl_ls.py +++ b/jc/parsers/systemctl_ls.py @@ -35,12 +35,13 @@ import jc.utils class info(): version = '1.0' - description = 'systemctl list-sockets parser' + description = 'systemctl list-sockets command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['systemctl list-sockets'] __version__ = info.version diff --git a/jc/parsers/systemctl_luf.py b/jc/parsers/systemctl_luf.py index e169da5f..a049d351 100644 --- a/jc/parsers/systemctl_luf.py +++ b/jc/parsers/systemctl_luf.py @@ -32,12 +32,13 @@ import jc.utils class info(): version = '1.0' - description = 'systemctl list-unit-files parser' + description = 'systemctl list-unit-files command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux'] + magic_commands = ['systemctl list-unit-files'] __version__ = info.version diff --git a/jc/parsers/uname.py b/jc/parsers/uname.py index 1c4a6876..41876d56 100644 --- a/jc/parsers/uname.py +++ b/jc/parsers/uname.py @@ -31,12 +31,13 @@ import jc.utils class info(): version = '1.1' - description = 'uname -a parser' + description = 'uname -a command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin'] + magic_commands = ['uname'] __version__ = info.version diff --git a/jc/parsers/uptime.py b/jc/parsers/uptime.py index 61a05508..bf0bc2c5 100644 --- a/jc/parsers/uptime.py +++ b/jc/parsers/uptime.py @@ -35,12 +35,13 @@ import jc.utils class info(): version = '1.0' - description = 'uptime parser' + description = 'uptime command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['uptime'] __version__ = info.version diff --git a/jc/parsers/w.py b/jc/parsers/w.py index 8bae56e7..119ad5c5 100644 --- a/jc/parsers/w.py +++ b/jc/parsers/w.py @@ -84,12 +84,13 @@ import jc.utils class info(): version = '1.0' - description = 'w parser' + description = 'w command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['w'] __version__ = info.version diff --git a/setup.py b/setup.py index f1382252..e0db21c3 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open('README.md', 'r') as f: setuptools.setup( name='jc', - version='1.7.2', + version='1.7.3', author='Kelly Brazil', author_email='kellyjonbrazil@gmail.com', description='This tool serializes the output of popular command line tools and filetypes to structured JSON output.',