Handy blog post for using getopts with bash. Used recently at work.