Live data from Hacker News

JC – JSONifies the output of many CLI tools

kellyjonbrazil.github.io

121–130 of 136 posts

Re: JC – JSONifies the output of many CLI tools

#121
post #9

Been using this a while to pull out a bunch of server stats for a monitoring dashboard and it's been great. I just wish there were more supported services. The total mess of different outputs and config types for Linux packages is extremely annoying to deal with.

Feel free to open issues on GitHub if you would like to recommend parsers! Also, the latest version of jc supports parsing of /proc files, which may also help.

Re: JC – JSONifies the output of many CLI tools

#122
post #69

There are at least 3 ways this can create bugs: - It has to parse output of commands which may or may not be intended to be parsed and may or may not have a predictable format. The only way to overcome this is if this program becomes one of the Big Four "UN*X command output -> data" converters - It casts things to "float/int" - Depending on who made this library, the output itself may not be strict / predictable. Per…

Hi - jc author here. Just a couple points:

The casting to int/float is not done unless the underlying values are predictably documented to be numbers. There are rare cases where auto int/float conversions are done, but:

1) This is always documented, and

2) You can turn this functionality off via the —raw flag

Also, predictable schemas are documented with each parser. (e.g `jc -h —-arp`)

Re: JC – JSONifies the output of many CLI tools

#123
post #52

Earlier quoted context omitted.

I would wish for jq to be a really generic tool for working with structured data on the commandline, but I have a really hard time figuring out how to do e.g. conditional-based editing etc. Can't get my head around that, and don't find any info about it on the net. Seems even something that just supports SQL (upon JSON) would be better in this regard.

What do you mean by conditional-based editing? I've found its language to be pretty concise and readable, especially with the // operator.

Doing editing only on selected "rows" or items in a structure, based on the values of other attributes in them. Similar to what you specify in the WHERE clause in SQL-statements.

Re: JC – JSONifies the output of many CLI tools

#124

Earlier quoted context omitted.

If we're adding standard output fds, maybe it would be a useful time to define any mechanism for consumers of those fds to discern the total ordering of bytes written to the three of them.

WC has a "character" flag that really just counts bytes: $ echo דותן | wc -c 9 Note that each letter is two bytes, and the newline is an additional byte. So you could pipe (or tree) to wc to count bytes. For a hypothetical stdmeta on fd 3, that might look like this (piping stdout to devnull): $ foo 3>&1 > /dev/null | wc -c

For the avoidance of doubt, it's not a bug that -c counts bytes, not characters.

There's a separate option for counting characters: -m

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/w...

Re: JC – JSONifies the output of many CLI tools

#125
post #69

There are at least 3 ways this can create bugs: - It has to parse output of commands which may or may not be intended to be parsed and may or may not have a predictable format. The only way to overcome this is if this program becomes one of the Big Four "UN*X command output -> data" converters - It casts things to "float/int" - Depending on who made this library, the output itself may not be strict / predictable. Per…

> Big Four "UN*X command output -> data" converters

What do you mean?

Re: JC – JSONifies the output of many CLI tools

#126
post #9

Been using this a while to pull out a bunch of server stats for a monitoring dashboard and it's been great. I just wish there were more supported services. The total mess of different outputs and config types for Linux packages is extremely annoying to deal with.

Feel free to open issues on GitHub if you would like to recommend parsers! Also, the latest version of jc supports parsing of /proc files, which may also help.

Thanks, certainly will do :) Wasn't aware that proc was now supported!

Re: JC – JSONifies the output of many CLI tools

#127
Something like this is what I've been thinking is the path forward to non-posix shells and a way to get away from cumbersome foot-gunny bash.

Nushell that hit the front page earlier this week seemed to me to be limited by "compatible" apps, but wrapping all the big ones in a json converter superficially seems like a great solution to me.

Re: JC – JSONifies the output of many CLI tools

#128

Earlier quoted context omitted.

There is such a thing as no-stdlib Rust deployments.

which is for MCUs only and is like a bare metal language without any libraries, its use is very limited. all I need is that rust's stdlib can be linked dynamically just like c/c++/java/whatever, if that happens I'm ready to switch to it.

It seems like you have multiple binaries (otherwise, I don't see how you would save space) in a context without an operating system, but do have abstractions like a linker; throwing this out there, you may be able to sort of fake having dynamically linked binaries with transparent disk compression. The shared code gets compressed, and you trade the overhead of your linker for the overhead of your compression, and probably roughly break even.

Re: JC – JSONifies the output of many CLI tools

#129

Earlier quoted context omitted.

which is for MCUs only and is like a bare metal language without any libraries, its use is very limited. all I need is that rust's stdlib can be linked dynamically just like c/c++/java/whatever, if that happens I'm ready to switch to it.

It seems like you have multiple binaries (otherwise, I don't see how you would save space) in a context without an operating system, but do have abstractions like a linker; throwing this out there, you may be able to sort of fake having dynamically linked binaries with transparent disk compression. The shared code gets compressed, and you trade the overhead of your linker for the overhead of your compression, and pro…

nope,not even close,the final size of a few binaries is at least 10x larger

Re: JC – JSONifies the output of many CLI tools

#130

Earlier quoted context omitted.

Following the project documentation, you easily come to: jc dig example.com | jq [ { "id": 30081, "opcode": "QUERY", "status": "NOERROR", "flags": [ "qr", "rd", "ra" ], "query_num": 1, "answer_num": 1, "authority_num": 0, "additional_num": 1, "opt_pseudosection": { "edns": { "version": 0, "flags": [], "udp": 4096 } }, "question": { "name": "example.com.", "class": "IN", "type": "A" }, "answer": [ { "name": "example.c…

For me there are too many quotes and brackets. My proposed format can also be converted to JSON if necessary.

Also note that you are looking at plaintext output here. By default `jc` and other JSON filtering tools do syntax highlighting when outputting to the terminal so it's actually quite easy to read JSON these days.
Post reply on HN