OptionParser is designed for a fixed set of options. But if the first argument is a command that can affect which options are available, then OptionParser can still be used with some clever coding.
#!/usr/bin/env python
# $Id: options.py 17 2013-11-07 03:43:22Z andrewfn $
"""Demo of using OptionParser where the first argument is a command that can take variable options.
The help system is totally automated and the framework is very easy to use."""
ver = 1.0 #put version number here
use = {}
#put the commands in here, with the integer giving the number of extra arguments