diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-21 23:01:48 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-21 23:01:48 -0400 |
commit | 11cb8c0f80197e6fe548b1d2ff72c1ed2bab39e3 (patch) | |
tree | bd1cd879f1d4e163bb4503c4de5e9de040ce862f | |
parent | 2b4dcaf8b5f3b759bb9973ee4a10c426a6fbb425 (diff) | |
download | cmd2-git-11cb8c0f80197e6fe548b1d2ff72c1ed2bab39e3.tar.gz |
Added comment
-rw-r--r-- | cmd2/argparse_custom.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index 668f41d6..3f1cb212 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -81,8 +81,7 @@ Tab Completion: parser.add_argument('-o', '--options', completer_method=cmd2.Cmd.path_complete) - In all cases in which function/methods are passed you can use functools.partial() to prepopulate - values of the underlying function. + You can use functools.partial() to prepopulate values of the underlying choices and completer functions/methods. Example: This says to call path_complete with a preset value for its path_filter argument. @@ -90,6 +89,11 @@ Tab Completion: path_filter=lambda path: os.path.isdir(path)) parser.add_argument('-o', '--options', choices_method=completer_method) + Of the 5 tab-completion parameters, choices is the only one where argparse validates user input against items + in the choices list. This is because the other 4 parameters are meant to tab complete data sets that are viewed + as dynamic. Therefore it is up to the user to validate if the user has typed an acceptable value for these + arguments. + CompletionItem Class: This class was added to help in cases where uninformative data is being tab completed. For instance, tab completing ID numbers isn't very helpful to a user without context. Returning a list of CompletionItems |