buckket / twtxt

Decentralised, minimalist microblogging service for hackers.
http://twtxt.readthedocs.org/en/stable/
MIT License
1.92k stars 79 forks source link

support for a pre_tweet_hook configuration parameter #32

Closed kitchen closed 8 years ago

kitchen commented 8 years ago

The motivation behind this is that I have 2 laptops which I use frequently, so I'd want to do something like s3cmd get <remote-file> to grab the latest official version of my stream before writing and re-uploading. You could also do this with a git repo and have the hook do a git pull or whatever (which is what I may end up doing, but for now I'm using an "s3" bucket)

This is 90% done. The remaining 10% I need help with, as I'm not familiar with Click or with python in general.

I want to abort execution if the pre_tweet_hook fails, so we don't end up uploading a stale file (which happened while I was testing this, oops!) but I'm not certain how best to do it. I tried raising a click.UsageError but that didn't seem correct. click.Abort just prints out "Aborted!" and exits, but doesn't say anything useful. The other click exceptions don't seem to be relevant, and raising an Exception (which is what I currently have it doing) horks up a stack trace and some not-very-friendly text.