summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-13 17:07:24 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-13 17:07:24 -0400
commitcdc0efa08e61f35a84c6af48d8a466c63dc50669 (patch)
tree0a6fd3012807c36ba3ab54fe515239bc5dff16c8 /cmd2
parent8acd840d0920519af4a862648827b8db0b72af76 (diff)
downloadcmd2-git-cdc0efa08e61f35a84c6af48d8a466c63dc50669.tar.gz
Updated documentation
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/argparse_custom.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py
index 5071989d..59a00f4c 100644
--- a/cmd2/argparse_custom.py
+++ b/cmd2/argparse_custom.py
@@ -102,6 +102,20 @@ Tab Completion:
set_completer_function(action, func)
set_completer_method(action, method)
+ There are times when what's being tab completed is determined by a previous argument on the command line.
+ In theses cases, Autocompleter can pass an argparse Namespace that maps the command line tokens up through the
+ one being completed to their argparse argument. To receive this Namespace, your choices/completer function
+ should have an argument called arg_tokens.
+
+ Example:
+ def my_choices_method(self, arg_tokens)
+ def my_completer_method(self, text, line, begidx, endidx, arg_tokens)
+
+ All members of the arg_tokens Namespace are lists, even if a particular argument expects only 1 token. Since
+ AutoCompleter is for tab completion, it does not convert the tokens to their actual argument types or validate
+ their values. All tokens are stored in the Namespace as the raw strings provided on the command line. It is up to
+ the developer to determine if the user entered the correct argument type (e.g. int) and validate their values.
+
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