Hello folks,
If you ever have a need to write a command line script in Racket, you may be interested in the package I've just put up. Normally you'd write such scripts using Racket's built-in
command-line or
parse-command-line form. These offer a lot of functionality, but it takes time to learn how they work and the syntax is somewhat idiosyncratic. So, I've written a #lang that allows you to achieve the same functionality but with more familiar and extensible syntax,
#lang cli.
The language is composed of 5 forms -
help,
flag,
constraint,
program, and
run. With these 5 forms, you get all of the functionality of the built-in
parse-command-line form, and with syntax that's much simpler. In fact, the nontrivial forms of the language simply use Racket's normal function definition syntax, so there's very little to learn -- you basically write normal functions and they are implicitly wired to accept their inputs via the command line.
At the moment, the functionality offered is at parity with the built-in forms, but there are some planned additions that would make it more powerful, including
composable commands,
generalized constraints, and
argument schemas.
So if you write command line scripts, I encourage you to give it a try.
I also coincidentally came across the package
natural-cli by Sage Gerard. Looks like it provides some interesting features and in particular subcommands, which are absent in #lang cli. It very well may be that this package should be leveraged for semantics in #lang cli in the future (Sage if you'd like to add anything about what this package offers, please do).
Enjoy,
-Sid