Introduce baloodb CLI tool
ClosedPublic

Authored by michaelh on Mar 13 2018, 2:23 PM.

Details

Summary

This is the command line interface of database sanitizer

Test Plan

Run on command line
Example:

$ baloodb list --missing-only --device-id 2049 '/otto/'
Listing database contents...
Missing: device: 2049 inode: 5053 url: /tmp/otto/A
Missing: device: 2049 inode: 9441 url: /tmp/otto/B
Missing: device: 2049 inode: 9464 url: /tmp/otto/B/B.txt
Found 3 matching items
Elapsed: 87.7154 secs

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
michaelh created this revision.Mar 13 2018, 2:23 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptMar 13 2018, 2:23 PM
michaelh requested review of this revision.Mar 13 2018, 2:23 PM

This is really nice, I like it! Should make debugging a lot easier. Noticed a couple of things:

$ baloodb -v
baloodb

$ baloodb devices
command "devices"
Listing database contents...
Device:2049 14855 items
Found 14855 matching items
Elapsed: 0.326553 secs
michaelh updated this revision to Diff 29524.Mar 14 2018, 7:45 PM
michaelh edited the test plan for this revision. (Show Details)
  • Add KAboutData
  • Remove debug statement
michaelh updated this revision to Diff 29525.Mar 14 2018, 7:48 PM
  • Remove obsolete include
michaelh added a comment.EditedMar 14 2018, 8:12 PM

This is really nice, I like it! Should make debugging a lot easier. Noticed a couple of things:

This is how the output now does and nearly should look.

$ baloodb devices
Listing database contents...
Device:22 3 items     
Device:43 76 items
Device:42 3627 items
Device:41 40 items
Device:2053 6438 items
Device:2049 22 items
Device:2069 1533 items
Device:2066 11643 items
Device:2064 99 items
Device:2086 220 items
Device:2098 1450 items
Found 25151 matching items
Elapsed: 4.42067 secs

or

$ baloodb devices 2>/dev/null
Device:22 3 items
Device:41 40 items
Device:42 3627 items
Device:43 76 items
Device:2069 1533 items
Device:2064 99 items
Device:2066 11643 items
Device:2053 6438 items
Device:2049 22 items
Device:2098 1450 items
Device:2086 220 items

The "found items" count has to be fixed in D11285. Are there more things?

michaelh updated this revision to Diff 29694.Mar 16 2018, 7:30 PM
  • Rebase on master
  • Improve help message
michaelh edited the test plan for this revision. (Show Details)EditedMar 16 2018, 7:37 PM

Should there be a note in --help message like "This is an experimental tool. The command line interface is subject to change."?

mlaurent requested changes to this revision.Mar 19 2018, 1:20 PM
mlaurent added a subscriber: mlaurent.
mlaurent added inline comments.
src/tools/baloodb/main.cpp
104

extra space at the end of i18n

113

const auto &c ?

125

coding style: remove space after()

132

options.count() == 0 => isEmpty()

136

very hard to read it.
Could you split in several QString so it will more easy to check it's if ok :)

204

!isEmpty()

This revision now requires changes to proceed.Mar 19 2018, 1:20 PM
michaelh added inline comments.Mar 19 2018, 1:53 PM
src/tools/baloodb/main.cpp
136

I had trouble myself :)

162

To point this out. I'm not the maintainer of baloo. Maybe better remove this?

michaelh updated this revision to Diff 29914.Mar 19 2018, 1:54 PM
  • Improve readability and apply other suggested changes
michaelh marked 4 inline comments as done.Mar 19 2018, 1:56 PM
ngraham added inline comments.Mar 19 2018, 1:58 PM
src/tools/baloodb/main.cpp
66

Any reason not to use a std::vector instead?

162

I think you sort of are Baloo's de facto maintainer (which is a good thing, and you've earned the position)!

michaelh added inline comments.Mar 19 2018, 3:45 PM
src/tools/baloodb/main.cpp
66

No reason. Will change to std::vector.

mlaurent requested changes to this revision.Mar 20 2018, 7:14 AM
mlaurent added inline comments.
src/tools/baloodb/CMakeLists.txt
17

install(TARGETS baloodb ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

src/tools/baloodb/main.cpp
152

const QString allCommandStr

This revision now requires changes to proceed.Mar 20 2018, 7:14 AM
michaelh updated this revision to Diff 29969.Mar 20 2018, 7:28 AM
  • Apply suggested changes
michaelh marked 7 inline comments as done.Mar 20 2018, 7:34 AM
michaelh added inline comments.
src/tools/baloodb/CMakeLists.txt
17

@mlaurent Is it worth the effort to change this for the other cli tools accordingly?

src/tools/baloodb/main.cpp
152

More const than suggested

mlaurent added inline comments.Mar 20 2018, 8:08 AM
src/tools/baloodb/CMakeLists.txt
17

It's the default variable.
But don't chnage it in this patch.
Perhaps in the future as you are the baloo maintainer :)

mlaurent accepted this revision.Mar 20 2018, 8:21 AM
This revision is now accepted and ready to land.Mar 20 2018, 8:21 AM
This revision was automatically updated to reflect the committed changes.
michaelh marked 2 inline comments as done.