Coder Social home page Coder Social logo

Comments (4)

StarOfSlytherin avatar StarOfSlytherin commented on May 19, 2024 1

Looks like I can use jq -s. I'm getting some errors but I can fix that. Thanks for the help!

from rich-cli.

harkabeeparolus avatar harkabeeparolus commented on May 19, 2024

You can format command output, as proven by your echo example. So I do not think that this is a problem with Rich.

I don't have access to the mosquitto_sub command, but I assume the problem is that it does not output a complete JSON document and close STDOUT. For example, tail -f does not work either, because it produces continuous output and never closes the file, so this example hangs forever:

$ echo '{"test":"OK"}' | tee foo.json
{"test":"OK"}
$ tail -f foo.json | rich --json -
[No output]

As long as the command that you execute finishes, and closes the pipe, you can format the output with Rich. If it doesn't, you can't. And since JSON specifically will be invalid if you don't have the entire file, it's not really technically possible to try to do anything different.

(This is in contrast with JSON Lines, JSONL, which you could certainly stream one line at a time.)

from rich-cli.

StarOfSlytherin avatar StarOfSlytherin commented on May 19, 2024

Thanks, I did not think that streaming JSON would be different from a normal JSON.

(This is in contrast with JSON Lines, JSONL, which you could certainly stream one line at a time.)

Does Rich CLI support this?

from rich-cli.

harkabeeparolus avatar harkabeeparolus commented on May 19, 2024

As far as I can tell, rich-cli does not support JSONL. See also: #59

I don't believe it would be very difficult to add if there is enough interest. However, it's easy to convert JSONL to JSON with jq -s so that's what I would recommend. 😊

from rich-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.