I was having a bit of a new year tidy up and found a lingering todo item about converting my Joy programme to a command line application so I thought I'd actually take a look at doing it as opposed to letting it hide on my Someday list for another year; the only problem with my Taskwarrior Someday list is that it is even more tucked away than it was under Teuxdeux.

I wrote a little wrapper programme that imports the joycog.joy programme and passes the arguments to it. Again, it is actually quite succinct uncommented:

"HOME" getenv 
"/" concat
"Code/github/atomicules/joycog/joycog.joy" 
concat include.
argv rest 
dup
2 take 
swap
2 drop
[0 strtol] map
swap 
[0 strtol] map
swap
joycog
put.
"\n" putchars.

A few points of note (see the commented version on github for more detail:

  • I've managed to make it fairly portable by using the getenv function so the path to joycog.joy can be relative (Joy has a lot of functionality, it is a lot more complete than I initially thought; the only thing stopping people writing full programmes in it is cognitive capacity).
  • rest is used to drop the first argument that argv provides which is the filename (or filepath, can't remember) being executed
  • strtol is used to convert the arguments from string to integers
  • putchars is used to print a blank line and make output on the command line a bit tidier
  • I discovered it is important to execute joy from the same directory as the standard libraries (usrlib, inilib and agglib) so it loads them automatically - I don't think there is a way to otherwise pass the path to these libraries to joy so it can find them.