choice ‐ the dyslexic option parser

What is this?

Choice is a parser for command-line options with support for fuzzy option matching and generating command completion.

It is just two files and not even a thousand NLOC with all the bells and whistles you can ask for.

Warning: this is still a work-in-progress.

Why should I need this?

I spend most of my day in xterm and OS X' Terminal. There's a lot of typing going on. There are so may awesome command-line utilities out there, but I wish there were more of them.

As a heavy command-line user, I've grown pretty accustomed to the behaviour of getopt(). The combination of long and short options works surprisingly well. I don't care what parses the options.

But when I write yet-another-utility-program, what I'm often struggling with is designing the command-line switches for a great experience. More often than not, I just want to get the job done, and couldn't care less about the usability.

But usability matters. So to solve the problem once and for all, here is one more option parser. There's no excuse anymore for those crufty while-switch loops.

I can not recall how many ad-hoc option parsers I have written, but it's probably been a few too many. You start with a simple loop, looking for the one single flag you program understands and it goes downhill from there. After a short struggle, you end up sucking it up to getopt and its not quite portable cousin getopt_long and that is that.


Download

Choice is not really a library. Instead there is just two files to drop into your source code.

Experiment

Don't know if this is what you're looking for?

Have a look at the API and some example code!

Participate

Want to help? Missing a feature? Having a hard time using it?

Check out the links below!