I always said that had I had a smartphone I would have stuck with Teuxdeux all along. There is something about it that just sits right with me, hence all my efforts to emulate it with Taskwarrior.

So it was no surprise I switched back when the opportunity finally arose. But I'm still keen to be able to accomplish as much as I can via the Terminal on NetBSD - I'll accept platform agnosticism over owning every byte of my own data. I'd stumbled across dmi3/teuxdeux in the meantime (wilderness years) which was really interesting to me as I'd spent a huge amount of time playing with curl trying to figure out the neux API when it was first (not actually) released and could never get it to work. Thanks to dmi3/teuxdeux I realised it must actually be possible to work with the new non-API.

The first mistake

After playing much more I finally realised that the whole (well, 98%) reason I couldn't get things to work was because I'd been misspelling "authenticity". I checked. Four years ago in my curl calls I was spelling it "authencity". Doh! I'm pretty sure I would have persevered had I realised.

The second mistake

What the hell, things still didn't work?! After much more confusion I then realised in the put request had "vi" and not "v1" for the URL. Typos have screwed me up a lot, but this is taking the biscuit.

The third mistake

I'll accept this one. The next reason why I failed to get this to work was because I'd not used the "-L" parameter (follow location) on curl when logging on. That was significant and I only ended up trying that after stumbling across this old blog post, Using curl with a web site secured by Rails Authenticity Token.

The last mistake

Since in my attempts to get this to work I'd long dropped back from Haskell to straight use of curl, the last mistake I'd made was a misunderstanding of the curl man page. I thought you could just use --cookie-jar for writing and reading cookies, but you can't you need to use it in conjunction with --cookie for reading and sending the cookies, --cookie-jar is just for saving cookies.

Mistakes I realised I'd made last time

After finally getting to the point where I could logon on make simple api calls on the command line I started changing the Haskell app to suit, still using Network.Curl even though very out of date, because it still (seemed to) work and the state of other options seemed incomplete and confusing as it was a few years ago. I also realised I'd done a lot of bad things originally, like recreating the curl object anew on each method so I improved that and passed about a curl object instead.

I had things "working" again with Network.curl, apart from I couldn't figure out what it was doing with cookies. As far as I could tell it seemed to be handling them in memory. The CurlCookie options worked and were necessary, but it didn't actually seem to be saving the cookies to a file anywhere. I ended up having to re-logon everytime.

Not a mistake, but a change

Even after that work-around though I ran into a road block with PUT requests. They seemingly should have worked via Network.Curl, but I eventually had to conclude they didn't.

I admitted defeat and went for straight system calls instead since I knew the command line worked. It doesn't make it spectacularly Haskelly, but it does mean it works.

Same, but different

So after a few months I'm finally back to the exact same functionality I had a few years ago. The only real differences are:

  • Uses boring system calls instead of a nice Haskelly way (but it is all the same deep under the surface, right?) and so doesn't have as a nice way of checking for returns like it did with 200 status codes when using Network.Curl.
  • You (and by that I mean "I") can only logon with netrc (which suits me).
  • It doesn't pass credentials all the time (because of the change in the API) which is a lot better, but it might mean when the cookies eventually expire you'd (I'd) have to reset the login by removing the cached auth token.
  • I can't be bothered to make it better (I had faint hope the first time, but no, it does what I want it to do)

Anyway, it's back alive again here: Haskerdeux.

There is no flashy fancy code to show off here, I just made it work again - that was achievement enough; The ironic thing about officially working in the Software/Technology industry is that I now have much less time for writing code than I did when I was "officially" a Mechanical Engineer.