Live data from Hacker News

JC – JSONifies the output of many CLI tools

kellyjonbrazil.github.io

11–20 of 136 posts

Re: JC – JSONifies the output of many CLI tools

#11
See also:

* "Bringing the Unix philosophy to the 21st century (2019)" (https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-ph...) - https://news.ycombinator.com/item?id=28266193 238 points | Aug 22, 2021 | 146 comments

* "Tips on adding JSON output to your CLI app" (https://blog.kellybrazil.com/2021/12/03/tips-on-adding-json-...) - https://news.ycombinator.com/item?id=29435786 183 points | 11 months ago | 110 comments

Re: JC – JSONifies the output of many CLI tools

#12

Then pipe it into jq [1] to query parameters or build up a formatted string. Or pipe it into rq [2] to convert the format to yaml, toml etc. [1]: https://stedolan.github.io/jq/tutorial/ [2]: https://github.com/dflemstr/rq#format-support-status

There's also https://github.com/TomWright/dasel (supports JSON, TOML, YAML, XML and CSV)

Re: JC – JSONifies the output of many CLI tools

#14
Great idea, but sounds like a maintenance nightmare to me. Not only that many users will complain that their favorite CLI tool isn't supported, but also a new release of any of the supported CLI tools might break the support without any kind of warning, as I don't think changes to the (human-readable) output are considered major changes.

Re: JC – JSONifies the output of many CLI tools

#15
Seems to be part of the Arch repository: https://archlinux.org/packages/community/any/jc/

Why does this site recommend using "paru", "aura" or "yay" to install it on Arch? I have been using Arch for a decade or so but have never even heard of such tools. They don't even have pages in the Arch wiki, and only yay ("Pacman wrapper and AUR helper written in go") is available via the standard repository.

Begs the question: what is so wrong with plain pacman?

EDIT: Okay so seems they were previously on AUR and once accepted to community repository they just forgot to stop recommending an AUR wrapper for installing: https://github.com/kellyjonbrazil/jc/commit/f2dd7b8815edc92e...

EDIT2: Created a PR with the GitHub.dev editor .. Absolutely blown away by how easy it was! Feels like the future of development.. https://github.com/kellyjonbrazil/jc/pull/310

Re: JC – JSONifies the output of many CLI tools

#16

Seems to be part of the Arch repository: https://archlinux.org/packages/community/any/jc/ Why does this site recommend using "paru", "aura" or "yay" to install it on Arch? I have been using Arch for a decade or so but have never even heard of such tools. They don't even have pages in the Arch wiki, and only yay ("Pacman wrapper and AUR helper written in go") is available via the standard repository. Begs the question…

It's a program to wrap stable CLI programs, makes sense that they recommend a wrapper around a stable program like pacman

Re: JC – JSONifies the output of many CLI tools

#17

Seems to be part of the Arch repository: https://archlinux.org/packages/community/any/jc/ Why does this site recommend using "paru", "aura" or "yay" to install it on Arch? I have been using Arch for a decade or so but have never even heard of such tools. They don't even have pages in the Arch wiki, and only yay ("Pacman wrapper and AUR helper written in go") is available via the standard repository. Begs the question…

Looking at github, it was only moved from AUR in May this year, but the commit only changed the description, not the commands.

But this is 100% going in my toolbox - I can think of a couple of scripts that I can update to use this right of the bat!

Re: JC – JSONifies the output of many CLI tools

#18
post #14

Great idea, but sounds like a maintenance nightmare to me. Not only that many users will complain that their favorite CLI tool isn't supported, but also a new release of any of the supported CLI tools might break the support without any kind of warning, as I don't think changes to the (human-readable) output are considered major changes.

Changes to the human-readable output of most standard Unix tools are a big deal given the amount of scripts which depends on them. They commonly are seen as fairly stable to the point that even some non-Posix tools like e.g. apt, which doesn't have a stable CLI warns about it to stderr if you try to redirect it's output to a pipe[1].

If anything, though, that's a good reason for a tool like this to exist rather than have every script that depends on these tools use their own, often hacky, parsing of the output.

[1] "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."

Re: JC – JSONifies the output of many CLI tools

#19
post #8

Last year I looked for JSON output with the dig command on Linux but found the yaml option while reading the man page. It was handy. I always wondered why yaml/JSON output is not standard with Linux and Unix utilities for scripting needs. Anyway: dig +yaml google.com

Because neither yaml or JSON existed when most of these tools were written, and then people got used to the current outputs, and so it's very varying whether or not anyone has felt the pain enough to decide it's worth adding the option for another output format.
Post reply on HN