Skip to content

Commit 11cb8c0

Browse files
committed
Added comment
1 parent 2b4dcaf commit 11cb8c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd2/argparse_custom.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,19 @@ def my_completer_function(text, line, begidx, endidx):
8181
parser.add_argument('-o', '--options', completer_method=cmd2.Cmd.path_complete)
8282
8383
84-
In all cases in which function/methods are passed you can use functools.partial() to prepopulate
85-
values of the underlying function.
84+
You can use functools.partial() to prepopulate values of the underlying choices and completer functions/methods.
8685
8786
Example:
8887
This says to call path_complete with a preset value for its path_filter argument.
8988
completer_method = functools.partial(path_complete,
9089
path_filter=lambda path: os.path.isdir(path))
9190
parser.add_argument('-o', '--options', choices_method=completer_method)
9291
92+
Of the 5 tab-completion parameters, choices is the only one where argparse validates user input against items
93+
in the choices list. This is because the other 4 parameters are meant to tab complete data sets that are viewed
94+
as dynamic. Therefore it is up to the user to validate if the user has typed an acceptable value for these
95+
arguments.
96+
9397
CompletionItem Class:
9498
This class was added to help in cases where uninformative data is being tab completed. For instance,
9599
tab completing ID numbers isn't very helpful to a user without context. Returning a list of CompletionItems

0 commit comments

Comments
 (0)