lehitoskin/ivy

Command line enhancements and expansion

Closed this issue · 5 comments

It would be nice to generally clean up and extend the command line capabilities of ivy, such that it is more useful for unix style scripting. Here's a potential list:

  • print search results more suitable for scripting
    • no summary line, e.g. Found 3 results for tags '("blerg")
    • exit when done
  • delete tags from image
    • -D or --delete-tags
  • add tags to image
    • -A or --add-tags
    • adds given tags to the list
  • set tags on image
    • -T or --set-tags
    • replaces any/all tags currently set with the specified tags
  • rename/move image on filesystem / update DB
    • -M or --move-image
    • keeps files associated with their database entries without having to cut, move, re-open, re-tag
    • possibly a lot of effort for an obscure feature

I rather like the convention of capital letters for possibly-destructive short options. Makes them more emphatic and requires a little more thought to type them.

I'd like to be able to do something like the following:

for img in (ivy -oe blerg)
    if test (file --mime-type "$img" | awk '{print $2}') -e "image/gif"
        ivy -D blerg "$img"
    end
end

no summary line, e.g. Found 3 results for tags '("blerg")

So then it would just be the strings of the images ivy has found. I gotcha. Do you think it would be worthwhile to add a (-0 | --null) flag, like find and xargs have where the results are separated by '\0' instead of '\n'?

rename/move image on filesystem / update DB
keeps files associated with their database entries without having to cut, move, re-open, re-tag

This is a thing that I come across every so often (I semi-frequently save images that already exist in the directory in perhaps a higher quality than the one I just saved). Does this mean that ivy would be the one moving the file and then retagging or just updating the database? If it's the latter of the two, I question how often I'd remember to use it. Perhaps we could put a "trial" sticker on it and see how well it works out.

Just a thought I had about the "-M" switch: we could have it so that it can move multiple images at once to new destinations, such as ivy -M <from ...> <to ...> where it would require an even amount of paths or else fail.

A -0 flag would be 100% okay with me; I didn't think of it because in practice I almost never use that feature when I'm using e.g. find with xargs. But if the goal is to be more unixy, and it's easy to add with the Racket console out libraries, then I'm onboard.

My thought with the move/rename command was that it would both move the file and update the database entry. It would be as simple as updating the path column; I don't think anything else should need to be poked.

The Principle of Least Surprise suggests it should probably behave like POSIX mv, where if there's more than 2 arguments, the last one is assumed to be a destination directory where all the preceding arguments are moved to, and an error is thrown if it's not.

and it's easy to add with the Racket console out libraries, then I'm onboard.

The change that would be needed is the result strings would need to become a single byte-string before printing, since the string "dog.jpg\0cat.jpg" would have the literal characters "" and "0" instead of a null byte, but that would be easy to change for the -0 switch.

It would be as simple as updating the path column; I don't think anything else should need to be poked.

The imagelist column in the tags table would need to be updated, too.

The Principle of Least Surprise suggests it should probably behave like POSIX mv

That makes sense.

Completed as of cbd707b