summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-07-13 00:34:43 +0000
committersteven.bethard <devnull@localhost>2009-07-13 00:34:43 +0000
commit849841ad0021e632141f9c7353bd98264b193fe2 (patch)
tree44c108ca1d3acf39811906c48819e9eb26c77364 /doc
parentbe051b2738ef9e459651e3c75a24f0ce97374d0c (diff)
downloadargparse-849841ad0021e632141f9c7353bd98264b193fe2.tar.gz
Allow tuples for metavars.
Diffstat (limited to 'doc')
-rw-r--r--doc/source/add_argument.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/source/add_argument.rst b/doc/source/add_argument.rst
index 667889f..43e1b29 100644
--- a/doc/source/add_argument.rst
+++ b/doc/source/add_argument.rst
@@ -378,6 +378,20 @@ If you would like to provide a different name for your argument in help messages
Note that ``metavar`` only changes the *displayed* name - the name of the attribute on the :meth:`parse_args` object is still determined by the dest_ value.
+Different values of ``nargs`` may cause the metavar to be used multiple times.
+If you'd like to specify a different display name for each of the arguments, you can provide a tuple to ``metavar``::
+
+ >>> parser = argparse.ArgumentParser(prog='PROG')
+ >>> parser.add_argument('-x', nargs=2)
+ >>> parser.add_argument('--foo', nargs=2, metavar=('bar', 'baz'))
+ >>> parser.print_help()
+ usage: PROG [-h] [-x X X] [--foo bar baz]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -x X X
+ --foo bar baz
+
dest
----