I really like using the boost http://boost.org program_options library. I could not find a worked example in the source so decided to create my own driven from tests. This is the result.
I also wrote a short article http://www.grahambrooks.com/blog/boost-program_options/ explaining the code.