cldwalker / logseq-query

MIT License
208 stars 8 forks source link

I/O strategy for processing output from lq #3

Closed sindoc closed 1 year ago

sindoc commented 1 year ago

Excellent work here.

I'm exploring the synergies between Logseq and command line [*] and in that spirit, what's you I/O strategy in terms of the format of the payload produced in standard output by lq? My requirement is to be able to query logseq and use other commands to process the results and that command itself can be registered back in Logseq for future use. It would be good if I could use jq to process the results of lq, for instance. But a few tests seem to reveal that lq doesn't produce well-formed JSON (?) Again, I might be wrong but I got the following when I tried:

$ lq q -g Documents lq/content-search action | jq parse error: Expected string key before ':' at line 1, column 3

[*] I think there's tremendous value in combining the power of Logseq and Command line. Logseq brings structured, yet chill storage and especially facilitates structured data input so it can be used to build semantic models, which can then be used to query effectively. I'm playing around with a simple set of assumptions we can make, to make the interaction smooth. Logseq connects us to the power of Web. And Command line keeps us grounded and resourceful because pretty much any function every written in the history of software, can be invoked via the command line (okay, surely some things might skip but in ant case, chances are you can bring them down to the cmd level).

In any case, I could also use your help in trying to figure out how to map a command line context to a Logseq context. This way, it should be easy to keep commands in sync with Logseq. I can share more details with you, if you're interested.

cldwalker commented 1 year ago

Hi. lq prints edn. edn is the most common data format in the clojure(script) world. If you'd like to convert to json you can use jet e.g.

 lq q -g Documents lq/content-search action | jet --to json | jq
sindoc commented 1 year ago

Thank you. Works like a charm!

cldwalker commented 1 year ago

Great!