The Register CLI
Hi all,
I've recently started using Beeminder to get back into the habit of doing some programming for personal projects every evening, as I've fallen out of the habit recently and it's something I've been wanting to commit more time to. I've also been signed up to beeminder for at least a year now (I never truly forgot thanks to their Monthly reminder email), but this month they ended up in a HumbleBundle with RescueTime which my subscription had lapsed on, so I decided to pick up the bundle and try to actually get into beeminding this time. My goal "cadawg/program-more" can be seen on the Beeminder website here.
Anyway, due to this, when I've gotten back and decided to do some programming now I have an extra reason to do so (it'll cost me if I don't) I haven't always wanted to work on existing projects, I certainly have and will (I gave ConfigDN some love on my first night of beeminding) but often I like making little projects I can finish fast in order to get back into the swing of it. To do this, I started building the The Register/El Reg CLI to refamiliarise myself with building CLIs in Go (it's been a few months since I last made one). I still like Go a lot for the fact that it is relatively easy to write working and sensible code. I wouldn't necessarily call the first implementation pretty or maintainable (and it had a bug or two), but I took to fixing them as tonight's task and I'm pretty happy with how it turned out - the code is way more maintainable now and readable, so if I do want to add a feature in the future, I won't have to jump into a pile of spaghetti.
The CLI allows you to browse The Register's homepage, and any article listed on it using a number. I simply chose it as it is a publication I like to read and I thought it'd be a cool little party trick and it certainly amused me.
I'm also quite fond of the ability to install a go library with a simple command, although I did manage to set the package's name to elreg-cli
in the go.mod which meant when I tried to install using the command above, it failed because it didn't match the full path go was expecting i.e. github.com/CADawg/elreg-cli
. I also managed to find a rather interesting bug as go's url.JoinPath
escapes the ?
in a query string, which only the first article has on the website, meaning that only opening article 0 would fail because it would % encode it as a literal part of the url (to a page that doesn't exist) which is something new I didn't know before, but certainly good to know for the future - and I suppose the function is made to handle paths and not query strings, so it makes sense it would behave like that.
Thanks for reading and have a lovely day.
~ CA
Like what I write? Subscribe to my Mailing List or RSS feed.
Comments? Questions? Feel free to send me an Email.
This post was last edited 7 months, 1 week ago.