balooctl status: Produce parseable output
ClosedPublic

Authored by michaelh on Jan 18 2018, 10:06 AM.

Details

Summary
  • introduced -f|--format command-line option
  • implemented formatters 'simple', 'json', 'multiline' (=current output)
Test Plan

$ balooctl status -h
$ balooctl status /existing/path/* /not/existing/path [--format xxx]
JSON well-formed check:
$ balooctl status /existing/path/* /not/existing/path -f json | jq '.'

Diff Detail

Repository
R293 Baloo
Branch
formatting
Lint
No Linters Available
Unit
No Unit Test Coverage
michaelh requested review of this revision.Jan 18 2018, 10:06 AM
michaelh created this revision.

Examples of each output would be nice.

balooctl status outputs:

I'm not too fond of assembling JSON by hand, but I guess it was done to avoid dependencies for a tool that's supposed to be simple. I'll let others weigh in on this.
Did you test this change also with filenames with Unicode characters or non-Latin characters?

src/tools/balooctl/statuscommand.cpp
122

Small nit: space after ":".

149

What do those replace operations do?

I'm not too fond of assembling JSON by hand, but I guess it was done to avoid dependencies for a tool that's supposed to be simple.

Qt's JSON support is in QtCore since Qt 5, there's no additional dependency, so yes, please use QJsonDocument et at.

@broulik: My reasons for not using it

  1. I was a little lazy: Using all the other Qt-Objects was enough work for me :).
  2. I thought not using QJsonDocument was accapteble because the overall structure of the formatters is similar.

Should you insist on QJsonDocument I'll use it of course.

src/tools/balooctl/statuscommand.cpp
122

This way one can

...  | cut -d ':' -f2-

otherwise you have to get rid of leading space.

149

escape double quotes

Did you test this change also with filenames with Unicode characters or non-Latin characters?

Yes. Example:

michaelh updated this revision to Diff 25591.Jan 18 2018, 1:19 PM

utilized QJson*
output:

michaelh marked 2 inline comments as done.Jan 18 2018, 1:27 PM

+1. @broulik How does it look on your side wrt the QJsonDocument usage?

Once I found an example (Qt doc) it was easy. Yesterday was struggling with this command line parsing to much :)
BTW, regarding

balooctl status -h

The --format look like a global switch. I don't like that. Couldn't find a(n easy) way to avoid that. Do you know one?
The subcommands are defined as posititional arguments after all.

The --format look like a global switch. I don't like that. Couldn't find a(n easy) way to avoid that. Do you know one?
The subcommands are defined as posititional arguments after all.

Apparently it's not possible in Qt (but I might be wrong).

Just learned it's on the Qt-wishlist. I can live with that. Just wanted to get rid of the 2nd description line.

michaelh retitled this revision from Parseable output for balooctl status to balooctl status: Produce parseable output.Jan 19 2018, 8:36 AM
michaelh edited the summary of this revision. (Show Details)
lbeltrame accepted this revision.Jan 20 2018, 8:19 AM

Changes are trivial enough IMO. Perhaps wait one or two days to see if anyone objects, then you can land this.

This revision is now accepted and ready to land.Jan 20 2018, 8:19 AM
This revision was automatically updated to reflect the committed changes.