summaryrefslogtreecommitdiff
path: root/examples/tab_autocompletion.py
diff options
context:
space:
mode:
authorkmvanbrunt <kmvanbrunt@gmail.com>2018-04-23 15:48:53 -0400
committerGitHub <noreply@github.com>2018-04-23 15:48:53 -0400
commitf11b06374aaf56b755de33a763220140d36eab64 (patch)
treec99bcdfcb3e73484e956c0e6df98da16fd6a44e4 /examples/tab_autocompletion.py
parentc9b676ab80872a61f5d843fc3804d14eca6786ba (diff)
parent4bc454f376c609e9bdf8e013d2b85c49c3ca1a6c (diff)
downloadcmd2-git-f11b06374aaf56b755de33a763220140d36eab64.tar.gz
Merge pull request #367 from python-cmd2/autocompleter
Autocompleter updates
Diffstat (limited to 'examples/tab_autocompletion.py')
-rwxr-xr-xexamples/tab_autocompletion.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/tab_autocompletion.py b/examples/tab_autocompletion.py
index 17c8391d..a1a8daee 100755
--- a/examples/tab_autocompletion.py
+++ b/examples/tab_autocompletion.py
@@ -95,6 +95,10 @@ class TabCompleteExample(cmd2.Cmd):
},
}
+ def instance_query_actors(self) -> List[str]:
+ """Simulating a function that queries and returns a completion values"""
+ return actors
+
# This demonstrates a number of customizations of the AutoCompleter version of ArgumentParser
# - The help output will separately group required vs optional flags
# - The help output for arguments with multiple flags or with append=True is more concise
@@ -222,7 +226,7 @@ class TabCompleteExample(cmd2.Cmd):
# tag the action objects with completion providers. This can be a collection or a callable
setattr(director_action, argparse_completer.ACTION_ARG_CHOICES, static_list_directors)
- setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, query_actors)
+ setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, instance_query_actors)
vid_movies_delete_parser = vid_movies_commands_subparsers.add_parser('delete')