I’ve been working on more projects to help teach myself to program in Nimrod, and this is the result of one of them. It’s a Nimrod wrapper for the Pastebin API. Currently it has the following functions:
- createPaste() – creates a new paste.
- createPasteFromFile() – creates a new paste from the contents of a file.
- createAPIUserKey() – creates a user session key, for use with other functions.
- listUserPastes() – lists a user’s pastes.
- listTrendingPastes() – lists the top 18 trending pastes.
- deletePaste() – deletes a paste.
- getUserInfo() – gets information about a user.
- getPaste() – gets the contents of a paste.
- getPasteToFile() – gets the contents of a paste and writes it to a file.
There are two functions I haven’t yet finished (listTrendingPastes() and listUserPastes()), but that’s just because Nimrod’s XML parsing modules are missing some pretty important functionality, and I’ll add them as soon as I figure out a way around that limitation. (There’s no ability to get the value of a Node, for example.)
EDIT: Turns out the functionality is there, but there are two method for working with XML and the documentation isn’t the clearest thing in the world. Back to work…
EDIT2: And all done.
In addition to the functions, there are two other modules, one (pastebin_constants.nim) that contains constants for privacy values and expiration dates and another (pastebin_formats.nim) that contains constants for the formats used for syntax highlighting.
The code is on GitHub, but I haven’t quite finished the documentation yet.