1616Example::
1717
1818 # -f argument expects at least 3 values
19- parser.add_argument('-f' , nargs=(3,))
19+ parser.add_argument("-f" , nargs=(3,))
2020
2121 # -f argument expects 3 to 5 values
22- parser.add_argument('-f' , nargs=(3, 5))
22+ parser.add_argument("-f" , nargs=(3, 5))
2323
2424
2525**Completion**
3838
3939 Example::
4040
41- my_list = [' An Option', ' SomeOtherOption' ]
42- parser.add_argument('-o', ' --options' , choices=my_list)
41+ my_list = [" An Option", " SomeOtherOption" ]
42+ parser.add_argument("-o", " --options" , choices=my_list)
4343
4444``choices_provider`` - pass a function that returns a Choices object. This is good in
4545cases where the choices are dynamically generated when the user hits tab.
@@ -50,6 +50,7 @@ def my_choices_provider(self) -> Choices:
5050 ...
5151 return my_choices
5252
53+
5354 parser.add_argument("arg", choices_provider=my_choices_provider)
5455
5556``completer`` - pass a function that does custom completion and returns a Completions object.
@@ -60,17 +61,16 @@ def my_choices_provider(self) -> Choices:
6061 Example::
6162
6263 # This adds file-path completion to an argument
63- parser.add_argument('-o', ' --options' , completer=cmd2.Cmd.path_complete)
64+ parser.add_argument("-o", " --options" , completer=cmd2.Cmd.path_complete)
6465
6566 You can use functools.partial() to prepopulate values of the underlying
6667 choices and completer functions/methods.
6768
6869 Example::
6970
7071 # This says to call path_complete with a preset value for its path_filter argument
71- dir_completer = functools.partial(path_complete,
72- path_filter=lambda path: os.path.isdir(path))
73- parser.add_argument('-o', '--options', completer=dir_completer)
72+ dir_completer = functools.partial(path_complete, path_filter=lambda path: os.path.isdir(path))
73+ parser.add_argument("-o", "--options", completer=dir_completer)
7474
7575For ``choices_provider`` and ``completer``, do not set them to a bound method. This
7676is because ArgparseCompleter passes the `self` argument explicitly to these
0 commit comments