I live in a bash environment. I create small programs frequently, in accordance with the UNIX way. I'm often creating command line programs. These days I'm often creating them in CoffeeScript.
I'd been using CoffeeScript's own OptionParse
to date, but found myself
wanting to distribute CoffeeScript compiled to JavaScript, without a dependency
on CoffeeScript at runtime. So long as I was shedding dependencies, I didn't
want to add a dependency on a command line parser library.
This file represents a swipe at a command line parser in CoffeeScript, that I can swipe for my command line programs when
[ foo, bar ] = process.argv.slice(2)
is no longer sufficient.
A command line library is useful for bash or C, where parsing the command line is a challenge, but in CoffeeScript, with regular expressions handy, it is pretty easy to chew through a command line, and do the right thing.
Because if your program is just a doodle, the command line interface doesn't need to be more than a doodle. If your program is meant to be a lean, mean command line machine, then your command line interface is too important to leave to a command line interface library mixin. This gist is a doodle to expand upon.
If you can read this, gists from git are working.