1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

revert column formatting

This commit is contained in:
Kelly Brazil
2022-01-23 13:40:50 -08:00
parent f285539526
commit b3896650c2
2 changed files with 62 additions and 104 deletions

View File

@ -1,19 +1,16 @@
![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg? ![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)
branch=master)
![Pypi](https://img.shields.io/pypi/v/jc.svg) ![Pypi](https://img.shields.io/pypi/v/jc.svg)
> `jc` was just featured in the [Console Open Source Newsletter](https:// > `jc` was just featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89)
console.substack.com/p/console-89)
> Check out the `jc` Python [package documentation](https://github.com/ > Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers
kellyjonbrazil/jc/tree/master/docs) for developers
> Try the `jc` [web demo](https://jc-web-demo.herokuapp.com/) > Try the `jc` [web demo](https://jc-web-demo.herokuapp.com/)
> JC is [now available](https://galaxy.ansible.com/community/general) as an > JC is [now available](https://galaxy.ansible.com/community/general) as an
Ansible filter plugin in the `community.general` collection. See this Ansible filter plugin in the `community.general` collection. See this
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in- [blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
ansible-with-jc/) for an example. for an example.
# JC # JC
JSON CLI output utility JSON CLI output utility
@ -71,8 +68,7 @@ will be a python dictionary, or list of dictionaries, instead of JSON:
``` ```
> For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or > For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or
see the [online documentation](https://github.com/kellyjonbrazil/jc/tree/master/ see the [online documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs).
docs).
Two representations of the data are available. The default representation uses a Two representations of the data are available. The default representation uses a
strict schema per parser and converts known numbers to int/float JSON values. strict schema per parser and converts known numbers to int/float JSON values.
@ -86,34 +82,24 @@ function parameter in `parse()`.
Schemas for each parser can be found at the documentation link beside each Schemas for each parser can be found at the documentation link beside each
[**Parser**](#parsers) below. [**Parser**](#parsers) below.
Release notes can be found [here](https://blog.kellybrazil.com/category/ Release notes can be found [here](https://blog.kellybrazil.com/category/jc-news/).
jc-news/).
## Why Would Anyone Do This!? ## Why Would Anyone Do This!?
For more information on the motivations for this project, please see my blog For more information on the motivations for this project, please see my blog
post on [Bringing the Unix Philosophy to the 21st Century](https://blog. post on [Bringing the Unix Philosophy to the 21st Century](https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/) and my [interview with Console](https://console.substack.com/p/console-89).
kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/)
and my [interview with Console](https://console.substack.com/p/console-89).
See also: See also:
- [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html) - [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html)
- [powershell](https://docs.microsoft.com/en-us/powershell/module/microsoft. - [powershell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7)
powershell.utility/convertto-json?view=powershell-7) - [blog: linux apps should have a json flag](https://thomashunter.name/posts/2012-06-06-linux-cli-apps-should-have-a-json-flag)
- [blog: linux apps should have a json flag](https://thomashunter.name/posts/
2012-06-06-linux-cli-apps-should-have-a-json-flag)
- [Hacker News discussion](https://news.ycombinator.com/item?id=28266193) - [Hacker News discussion](https://news.ycombinator.com/item?id=28266193)
- [Reddit discussion](https://www.reddit.com/r/programming/comments/pa4cbb/ - [Reddit discussion](https://www.reddit.com/r/programming/comments/pa4cbb/bringing_the_unix_philosophy_to_the_21st_century/)
bringing_the_unix_philosophy_to_the_21st_century/)
Use Cases: Use Cases:
- [Bash scripting](https://blog.kellybrazil.com/2021/04/12/practical-json-at-the - [Bash scripting](https://blog.kellybrazil.com/2021/04/12/practical-json-at-the-command-line/)
-command-line/) - [Ansible command output parsing](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
- [Ansible command output parsing](https://blog.kellybrazil.com/2020/08/30/ - [Saltstack command output parsing](https://blog.kellybrazil.com/2020/09/15/parsing-command-output-in-saltstack-with-jc/)
parsing-command-output-in-ansible-with-jc/) - [Nornir command output parsing](https://blog.kellybrazil.com/2020/12/09/parsing-command-output-in-nornir-with-jc/)
- [Saltstack command output parsing](https://blog.kellybrazil.com/2020/09/15/
parsing-command-output-in-saltstack-with-jc/)
- [Nornir command output parsing](https://blog.kellybrazil.com/2020/12/09/
parsing-command-output-in-nornir-with-jc/)
## Installation ## Installation
There are several ways to get `jc`. You can install via `pip`, OS package There are several ways to get `jc`. You can install via `pip`, OS package
@ -143,8 +129,8 @@ pip3 install jc
> For more OS Packages, see https://repology.org/project/jc/versions. > For more OS Packages, see https://repology.org/project/jc/versions.
### Binaries and Packages ### Binaries and Packages
For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/ For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/releases)
releases) on Github. on Github.
## Usage ## Usage
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the `jc` accepts piped input from `STDIN` and outputs a JSON representation of the
@ -407,18 +393,16 @@ local **"App data directory"**:
- Windows: `$LOCALAPPDATA\jc\jc\jcparsers` - Windows: `$LOCALAPPDATA\jc\jc\jcparsers`
Local parser plugins are standard python module files. Use the Local parser plugins are standard python module files. Use the
[`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/ [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/ or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py)
kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parser as a template and parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
simply place a `.py` file in the `jcparsers` subfolder.
Local plugin filenames must be valid python module names, therefore must consist Local plugin filenames must be valid python module names, therefore must consist
entirely of alphanumerics and start with a letter. Local plugins may override entirely of alphanumerics and start with a letter. Local plugins may override
default parsers. default parsers.
> Note: The application data directory follows the [XDG Base Directory > Note: The application data directory follows the
Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec- [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
latest.html)
### Caveats ### Caveats
@ -451,9 +435,9 @@ parsers that convert platform-specific output will generate a warning message if
they are run on an unsupported platform. To see all parser information, they are run on an unsupported platform. To see all parser information,
including compatibility, run `jc -ap`. including compatibility, run `jc -ap`.
You may still use a parser on an unsupported platform - for example, you may You may still use a parser on an unsupported platform - for example, you may want
want to parse a file with linux `lsof` output on an macOS or Windows laptop. In to parse a file with linux `lsof` output on an macOS or Windows laptop. In that
that case you can suppress the warning message with the `-q` cli option or the case you can suppress the warning message with the `-q` cli option or the
`quiet=True` function parameter in `parse()`: `quiet=True` function parameter in `parse()`:
macOS: macOS:
@ -480,20 +464,15 @@ Tested on:
- Windows 2019 Server - Windows 2019 Server
## Contributions ## Contributions
Feel free to add/improve code or parsers! You can use the [`jc/parsers/foo.py`]( Feel free to add/improve code or parsers! You can use the
https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
[`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/ or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull request.
master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a
pull request.
Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/ Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/blob/master/CONTRIBUTING.md) for more information.
blob/master/CONTRIBUTING.md) for more information.
## Acknowledgments ## Acknowledgments
- Local parser plugin feature contributed by [Dean Serenevy](https://github.com/ - Local parser plugin feature contributed by [Dean Serenevy](https://github.com/duelafn)
duelafn) - CI automation and code optimizations by [philippeitis](https://github.com/philippeitis)
- CI automation and code optimizations by [philippeitis](https://github.com/
philippeitis)
- [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module - [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module
by KnightWhoSayNi by KnightWhoSayNi
- [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech - [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech

View File

@ -1,19 +1,16 @@
![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg? ![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)
branch=master)
![Pypi](https://img.shields.io/pypi/v/jc.svg) ![Pypi](https://img.shields.io/pypi/v/jc.svg)
> `jc` was just featured in the [Console Open Source Newsletter](https:// > `jc` was just featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89)
console.substack.com/p/console-89)
> Check out the `jc` Python [package documentation](https://github.com/ > Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers
kellyjonbrazil/jc/tree/master/docs) for developers
> Try the `jc` [web demo](https://jc-web-demo.herokuapp.com/) > Try the `jc` [web demo](https://jc-web-demo.herokuapp.com/)
> JC is [now available](https://galaxy.ansible.com/community/general) as an > JC is [now available](https://galaxy.ansible.com/community/general) as an
Ansible filter plugin in the `community.general` collection. See this Ansible filter plugin in the `community.general` collection. See this
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in- [blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
ansible-with-jc/) for an example. for an example.
# JC # JC
JSON CLI output utility JSON CLI output utility
@ -71,8 +68,7 @@ will be a python dictionary, or list of dictionaries, instead of JSON:
``` ```
> For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or > For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or
see the [online documentation](https://github.com/kellyjonbrazil/jc/tree/master/ see the [online documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs).
docs).
Two representations of the data are available. The default representation uses a Two representations of the data are available. The default representation uses a
strict schema per parser and converts known numbers to int/float JSON values. strict schema per parser and converts known numbers to int/float JSON values.
@ -86,34 +82,24 @@ function parameter in `parse()`.
Schemas for each parser can be found at the documentation link beside each Schemas for each parser can be found at the documentation link beside each
[**Parser**](#parsers) below. [**Parser**](#parsers) below.
Release notes can be found [here](https://blog.kellybrazil.com/category/ Release notes can be found [here](https://blog.kellybrazil.com/category/jc-news/).
jc-news/).
## Why Would Anyone Do This!? ## Why Would Anyone Do This!?
For more information on the motivations for this project, please see my blog For more information on the motivations for this project, please see my blog
post on [Bringing the Unix Philosophy to the 21st Century](https://blog. post on [Bringing the Unix Philosophy to the 21st Century](https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/) and my [interview with Console](https://console.substack.com/p/console-89).
kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/)
and my [interview with Console](https://console.substack.com/p/console-89).
See also: See also:
- [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html) - [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html)
- [powershell](https://docs.microsoft.com/en-us/powershell/module/microsoft. - [powershell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7)
powershell.utility/convertto-json?view=powershell-7) - [blog: linux apps should have a json flag](https://thomashunter.name/posts/2012-06-06-linux-cli-apps-should-have-a-json-flag)
- [blog: linux apps should have a json flag](https://thomashunter.name/posts/
2012-06-06-linux-cli-apps-should-have-a-json-flag)
- [Hacker News discussion](https://news.ycombinator.com/item?id=28266193) - [Hacker News discussion](https://news.ycombinator.com/item?id=28266193)
- [Reddit discussion](https://www.reddit.com/r/programming/comments/pa4cbb/ - [Reddit discussion](https://www.reddit.com/r/programming/comments/pa4cbb/bringing_the_unix_philosophy_to_the_21st_century/)
bringing_the_unix_philosophy_to_the_21st_century/)
Use Cases: Use Cases:
- [Bash scripting](https://blog.kellybrazil.com/2021/04/12/practical-json-at-the - [Bash scripting](https://blog.kellybrazil.com/2021/04/12/practical-json-at-the-command-line/)
-command-line/) - [Ansible command output parsing](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
- [Ansible command output parsing](https://blog.kellybrazil.com/2020/08/30/ - [Saltstack command output parsing](https://blog.kellybrazil.com/2020/09/15/parsing-command-output-in-saltstack-with-jc/)
parsing-command-output-in-ansible-with-jc/) - [Nornir command output parsing](https://blog.kellybrazil.com/2020/12/09/parsing-command-output-in-nornir-with-jc/)
- [Saltstack command output parsing](https://blog.kellybrazil.com/2020/09/15/
parsing-command-output-in-saltstack-with-jc/)
- [Nornir command output parsing](https://blog.kellybrazil.com/2020/12/09/
parsing-command-output-in-nornir-with-jc/)
## Installation ## Installation
There are several ways to get `jc`. You can install via `pip`, OS package There are several ways to get `jc`. You can install via `pip`, OS package
@ -143,8 +129,8 @@ pip3 install jc
> For more OS Packages, see https://repology.org/project/jc/versions. > For more OS Packages, see https://repology.org/project/jc/versions.
### Binaries and Packages ### Binaries and Packages
For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/ For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/releases)
releases) on Github. on Github.
## Usage ## Usage
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the `jc` accepts piped input from `STDIN` and outputs a JSON representation of the
@ -323,18 +309,16 @@ local **"App data directory"**:
- Windows: `$LOCALAPPDATA\jc\jc\jcparsers` - Windows: `$LOCALAPPDATA\jc\jc\jcparsers`
Local parser plugins are standard python module files. Use the Local parser plugins are standard python module files. Use the
[`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/ [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/ or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py)
kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parser as a template and parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
simply place a `.py` file in the `jcparsers` subfolder.
Local plugin filenames must be valid python module names, therefore must consist Local plugin filenames must be valid python module names, therefore must consist
entirely of alphanumerics and start with a letter. Local plugins may override entirely of alphanumerics and start with a letter. Local plugins may override
default parsers. default parsers.
> Note: The application data directory follows the [XDG Base Directory > Note: The application data directory follows the
Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec- [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
latest.html)
### Caveats ### Caveats
@ -367,9 +351,9 @@ parsers that convert platform-specific output will generate a warning message if
they are run on an unsupported platform. To see all parser information, they are run on an unsupported platform. To see all parser information,
including compatibility, run `jc -ap`. including compatibility, run `jc -ap`.
You may still use a parser on an unsupported platform - for example, you may You may still use a parser on an unsupported platform - for example, you may want
want to parse a file with linux `lsof` output on an macOS or Windows laptop. In to parse a file with linux `lsof` output on an macOS or Windows laptop. In that
that case you can suppress the warning message with the `-q` cli option or the case you can suppress the warning message with the `-q` cli option or the
`quiet=True` function parameter in `parse()`: `quiet=True` function parameter in `parse()`:
macOS: macOS:
@ -396,20 +380,15 @@ Tested on:
- Windows 2019 Server - Windows 2019 Server
## Contributions ## Contributions
Feel free to add/improve code or parsers! You can use the [`jc/parsers/foo.py`]( Feel free to add/improve code or parsers! You can use the
https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
[`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/ or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull request.
master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a
pull request.
Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/ Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/blob/master/CONTRIBUTING.md) for more information.
blob/master/CONTRIBUTING.md) for more information.
## Acknowledgments ## Acknowledgments
- Local parser plugin feature contributed by [Dean Serenevy](https://github.com/ - Local parser plugin feature contributed by [Dean Serenevy](https://github.com/duelafn)
duelafn) - CI automation and code optimizations by [philippeitis](https://github.com/philippeitis)
- CI automation and code optimizations by [philippeitis](https://github.com/
philippeitis)
- [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module - [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module
by KnightWhoSayNi by KnightWhoSayNi
- [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech - [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech