getopts isn't very powerful. Take a look at how
prefix (specifically sections 2 through 4) parses arguments. If you want another example, look at
fsize.
Note this system is imperfect. Most notibly it doesn't yet support non-option arguments that start with a hyphen. I'll get to this when I have time (a lot of stuff builds up to read after being away over a three day weekend...).
I should make a shell based off Bash that incorporates this system in a builtin...