diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2008-01-19 21:01:39 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2008-01-19 21:01:39 (GMT) |
commit | af81c576ea441efb6c05aab31dc58b2792a5fdf2 (patch) | |
tree | 3ccb7ff11f99272260e27266fb623f5d35b84aa6 /Doc | |
parent | 7829d603a8f573ed393d00f26b7b81f18d1e8197 (diff) | |
download | cpython-af81c576ea441efb6c05aab31dc58b2792a5fdf2.zip cpython-af81c576ea441efb6c05aab31dc58b2792a5fdf2.tar.gz cpython-af81c576ea441efb6c05aab31dc58b2792a5fdf2.tar.bz2 |
Bug 1296: restore text describing OptionGroup
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/liboptparse.tex | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Doc/lib/liboptparse.tex b/Doc/lib/liboptparse.tex index cd1fb00..0b47638 100644 --- a/Doc/lib/liboptparse.tex +++ b/Doc/lib/liboptparse.tex @@ -558,6 +558,39 @@ default value is \code{None}), \code{{\%}default} expands to \code{none}. \end{itemize} +When dealing with many options, it is convenient to group these +options for better help output. An \class{OptionParser} can contain +several option groups, each of which can contain several options. + +Continuing with the parser defined above, adding an +\class{OptionGroup} to a parser is easy: + +\begin{verbatim} +group = OptionGroup(parser, ``Dangerous Options'', + ``Caution: use these options at your own risk. `` + ``It is believed that some of them bite.'') +group.add_option(``-g'', action=''store_true'', help=''Group option.'') +parser.add_option_group(group) +\end{verbatim} + +This would result in the following help output: + +\begin{verbatim} +usage: [options] arg1 arg2 + +options: + -h, --help show this help message and exit + -v, --verbose make lots of noise [default] + -q, --quiet be vewwy quiet (I'm hunting wabbits) + -fFILE, --file=FILE write output to FILE + -mMODE, --mode=MODE interaction mode: one of 'novice', 'intermediate' + [default], 'expert' + + Dangerous Options: + Caution: use of these options is at your own risk. It is believed that + some of them bite. + -g Group option. +\end{verbatim} \subsubsection{Printing a version string\label{optparse-printing-version-string}} |