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
<https://docs.racket-lang.org/reference/Command-Line_Parsing.html#%28form._%28%28lib._racket%2Fcmdline..rkt%29._command-line%29%29>
or
parse-command-line
<https://docs.racket-lang.org/reference/Command-Line_Parsing.html#%28def._%28%28lib._racket%2Fcmdline..rkt%29._parse-command-line%29%29>
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
<https://docs.racket-lang.org/cli/index.html>.

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
<https://github.com/countvajhula/cli/issues/3>, generalized constraints
<https://github.com/countvajhula/cli/issues/6>, and argument schemas
<https://github.com/countvajhula/cli/issues/7>.

So if you write command line scripts, I encourage you to give it a try.

I also coincidentally came across the package natural-cli
<https://docs.racket-lang.org/natural-cli/index.html> 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

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CACQBWFnevJaRg61xLv6ayps-ihGpuUFUFEVbLTH7m929tpex3Q%40mail.gmail.com.

Reply via email to