Write Freely Python Client Update
I had previously posted that I was going to work on a CLI client for posting content to Write Freely. I ended up having some distractions on that front as I got busy with things at work and briefly toyed with the idea of writing my client in Go instead of Python. While I may still circle back at some point on the language (I'm debating between using it as an excuse to learn Go or learn Rust at this point), I ultimately decided that—considering I use Python for the majority of my projects at work and I'm not exactly a master with it—it made the most sense to stick with Python for this project. I need to get good with one thing before I start trying to learn the next thing.
I actually made a decent bit of progress tonight, as is visible by the 2 commits I pushed. The big items I got nailed down were:
- Authentication to provide credentials and get an API key which is locally cached for future use.
- Logging out to invalidate the aforementioned API key and clear the locally cached content.
- Pushing posts via a path to a file.
- Pushing posts via content piped to STDIN.
All of this is subject to change as I'm currently just trying to get something working, and I'll clean things up later. Right now, testing is a little weird because I call
__main__ directly, given that I eventually intend to package this.
Regardless, it's cool to start seeing progress come together. I've worked on—and subsequently abandoned—similar projects for things like Mastodon and Tumblr, and I always end up running into hurdles with authentication. I could, and arguably should, skip the complexities of that immediately and circle back to it later, but I always end up feeling like I should work in order. Luckily, the API for Write Freely is very straight forward with respect to authentication.
In fact, it's very straightforward with respect to basically everything, and it's very well documented on top of that. Huge kudos for that.
Immediate next steps are going to include:
- Refining the output when posts are made. I'm not sure if it's possible from a quick glance at the documentation, but if it is I'd like to include a URL to the final post for ease of access to see the finished product.
- Allow for post deletion by running a command to query for post titles and IDs followed by a command to remove a post by ID.
Longer term next steps will be:
- Adding an interactive mode so that the
writepylycommand drops the user into a TUI, preferably created with something like Rich so that it looks swanky.
- Allow post management from the TUI.
- Allowing for post creation from the TUI.
In my next commit I'll probably try to update the project's README to reflect this as well. In the meantime, look for more garbage posts on my test blog that I set up so that I don't pollute this one with nonsense content in order to test my client.