optcomplete is a Python module that provides
programmable shell completion support for Python
scripts that use the optparse module. It
implements the Bash completion protocol, and a
simple common shell function invokes the script to
provide the completion suggestions. As an optparse
parser already contains most of the useful
information to provide completions, only two lines
of code are required to provide basic support for
completions to an existing script. It also allows
the developer to provide per-option completion, etc.