Tooting my own horn if I may, I'd also like to suggest taking a look at an option parsing library that I've written: dropt.
One feature that it offers that many others don't is the ability to override earlier options. For example, if you have a shell alias:
alias bar="foo --flag1 --flag2 --flag3"
and you want to use bar
but with--flag1
disabled, it allows you to do:
bar --flag1=0