vaeth / eix

eix can access Gentoo portage ebuild information and description very quickly (using a local cache). It can also be used to access information on installed packages, local settings, and local and external overlays, and informs about changes in the tree
GNU General Public License v2.0
163 stars 12 forks source link

[feature request] output in JSON format #71

Closed mrl5 closed 4 years ago

mrl5 commented 4 years ago

are there any chances to introduce a feature which will provide output in JSON format similar to https://github.com/vaeth/eix/blob/470c9d35ed91bfac3f808c5e8625c61a04234b8f/src/output/print-xml.h https://github.com/vaeth/eix/blob/470c9d35ed91bfac3f808c5e8625c61a04234b8f/src/output/print-xml.cc

vaeth commented 4 years ago

Sure, if you implement it. ;) I have meanwhile hardly time to write new code, but I suppose that I will still maintain eix for a while. (At least as long as there is not a new API which requires a rewrite of major parts of eix.) So if you write the code (and it is roughly in the style of rest of eix so that it can be maintained), I would gladly merge it. I suppose JSON output is simple enough that it is not necessary to introduce a dependency on some json library.

BTW, although I am not against JSON output: JSON like xml is not really human-readable and time-consuming to process. Personally, I would say that instead protobuf is the better way to go. In that case a build-time dependency on dev-libs/protobuf is probably reasonable, although perhaps the generated files might be included in the tarball (I would have to think about it...)

mrl5 commented 4 years ago

thanks for a quick reply! protobuf is indeed interesting - if I will have some time I'll try to contribute and do some PR (can't tell when)

vaeth commented 4 years ago

To get something started and communicate the route I had in mind, I checked into the master branch an experimental eix.proto file.

If you are not interested to work on it, I might continue to work on it when I find the time, but do not take my word granted on this.

vaeth commented 4 years ago

The ugly and cumbersome parts are done and in master: adding of command line flag, implementation in the two build systems (including calling protoc), adding to documentation and translations, using type inheritance to output in generic output format…

What remains to do now is the fun part: implementing the proto output class in print-proto.{cc,h}. It should be rather simple: Just proceed analogously to print-xml.{cc,h} to incrementally build (instead of outputting as for xml) the proto, and then serialize it in the finalize() method.

vaeth commented 4 years ago

rebased (amended) last commit to get only a clean version in the history which does not workaround the shortcomings of the meson build system in the .cc and .h source files.

Also already fetch/free main proto type. Only 2 methods need to be implemented now (marked with TODO).

mrl5 commented 4 years ago

hello @vaeth. Thanks for responsiveness. I appriciate that you added "velocity" to this feature. I will try to implement it when I will find some free time - this will be definitely fun

(side note) if in meanwhile someone will want to implement rest of the code I wont be mad :D

vaeth commented 4 years ago

if in meanwhile someone will want to implement rest of the code I wont be mad

I did it now and released it in v0.34.0.

Closing, although the original request was not addressed.

vaeth commented 4 years ago

Sorry, I changed my mind about the eix.proto. It will be tight more closely to eix internals and not contain the simplified xml data. I will release the new version 0.34.1 today, since I suppose that nobody was using the old eix.proto yet. In future, changes to eix.proto will be less intrusive, keeping the tag numbers if possible.