We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc5200a commit 3fe4002Copy full SHA for 3fe4002
argparse_dataclass.py
@@ -118,6 +118,20 @@
118
>>> print(parser.parse_args(["--name", "john doe"]))
119
Options(name='John Doe')
120
121
+Parsing a list of values:
122
+
123
+.. code-block:: pycon
124
125
+ >>> from dataclasses import dataclass, field
126
+ >>> from argparse_dataclass import ArgumentParser
127
+ >>> @dataclass
128
+ ... class Options:
129
+ ... names: list[str] = field(metadata=dict(type=str, nargs="+"))
130
+ ...
131
+ >>> parser = ArgumentParser(Options)
132
+ >>> print(parser.parse_args(["--names", "john", "jane"]))
133
+ Options(names=['john', 'jane'])
134
135
Configuring a flag to have a default value of True:
136
137
.. code-block:: pycon
0 commit comments