Parsing command line arguments on the shell is often done in an ad-hoc fashion, growing unwieldy as time goes by, but there are tools to make that elegant. Here’s a complete example.
I use this in the conf project (easy setup of autotools projects). It builds on the great solution by Adam Katz.