cli syntax (order of tag and file arguments when tagging)
The syntax of the tmsu binary sometimes gives somewhat unexpected results. For example, you would expect the command tmsu tag country=spain *.jpg to tag all .jpg files with the country=spain tag. Instead, it creates a bunch of new tags, which are not associated with anything as there is no file named country=spain. And I cannot replicate now, but somehow I managed to assign hundreds of names of files as tags to another file yesterday.
I know there is an alternative format tmsu tag --tag="country=spain" *.jpg which looks more like the format you'd expect from commands such as chmod, chown, chattr, getfattr, getfacl etc. But the other syntax is default and making the mistake of using it accidently is too easy.
Personally, I would prefer the syntax to be as follows: To add a tag country=spain to *.jpg: tmsu -a "country=spain" *.jpg To add multiple tags to a .jpg file: tmsu -a "country=spain" -a "year=2013" -a "city=barcelona" vacation.jpg To remove a tag country=spain to *.jpg: tmsu -x "country=spain" *.jpg List all tags: tmsu -l List all tags for a file: tmsu -l vacation.jpg Kinda like setfacl syntax
This would of course break backwards compatibility, but I believe in the long run, that will be worth it. You could fase out the current syntax out or add a switch to make it recognise new syntax. You could even make tmsu behave differently depending on what command was used to start it. Like busybox does: symlink it to another name, whole different behaviour. That way the command tmsu2 could react to new syntax while tmsu sticks to the current syntax.
If none of this is an option, I would at least suggest adding a config value that allows users to disable the [command] [file] [tags] format. Because a simple typo could seriously screw up the database now.
For the record, I tend to tag a single file with multiple tags more often than multiple files with a single tag, so I would lean to keeping the default. That said, I do think it is good to consider how the cli syntax could be improved as such.
On a side note, if you're having issues accidentally screwing up your tag database, you can keep it version controlled in git with a little effort:
$ sqlite3 <tmsu_root>/.tmsu/db .dump > tmsu.db.dump.sql
This will dump your database into an SQL file. You can then recreate the database like this:
$ sqlite db < tmsu.db.dump.sql
$ mv db <tmsu_root>/.tmsu/db
Which will overwrite the database with the one resurrected from the SQL. This means you essentially have your database in plain text and so can keep it in a git repo or whatever. If you wrap this all up in a bash script, then it's pretty painless.
Doing this has saved me a few times.
Hi, thanks for your suggestion. Sorry I have not got back to earlier only I have been on my annual holidays.
I agree that sometimes it's easy to mess up: I have done this myself and in the past and created a lot of nonsense tags. I'll have a think about how this could work but I think it would be a great loss to lose the tmsu tag somefile tag1 tag2 tag3 syntax, especially for those new to the tool.
I'll have a think about this, but my sentiment right now is that this won't change.