summaryrefslogtreecommitdiff
path: root/examples/tab_autocompletion.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-05-02 15:22:14 -0400
committerEric Lin <anselor@gmail.com>2018-05-02 15:22:14 -0400
commita55f0b6ed559d03f2d8b596898d638b288c11a68 (patch)
tree54d84c8d1d7c14247ac3a22186ed106190a8b494 /examples/tab_autocompletion.py
parentdbf4846e8bc0e6ca38c928d8fe4752f9b6173803 (diff)
parenta95c8a065abeac286c196783393ecc49e4356f54 (diff)
downloadcmd2-git-a55f0b6ed559d03f2d8b596898d638b288c11a68.tar.gz
Merge branch 'test_merge' into test_ply_merge
Diffstat (limited to 'examples/tab_autocompletion.py')
-rwxr-xr-xexamples/tab_autocompletion.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/tab_autocompletion.py b/examples/tab_autocompletion.py
index a1a8daee..f3302533 100755
--- a/examples/tab_autocompletion.py
+++ b/examples/tab_autocompletion.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# coding=utf-8
"""
A example usage of the AutoCompleter
@@ -10,14 +10,15 @@ import argparse
import itertools
from typing import List
-import cmd2
-from cmd2 import with_argparser, with_category, argparse_completer
+from cmd2 import cmd2, argparse_completer
+from cmd2.cmd2 import with_argparser, with_category
actors = ['Mark Hamill', 'Harrison Ford', 'Carrie Fisher', 'Alec Guinness', 'Peter Mayhew',
'Anthony Daniels', 'Adam Driver', 'Daisy Ridley', 'John Boyega', 'Oscar Isaac',
'Lupita Nyong\'o', 'Andy Serkis', 'Liam Neeson', 'Ewan McGregor', 'Natalie Portman',
'Jake Lloyd', 'Hayden Christensen', 'Christopher Lee']
+
def query_actors() -> List[str]:
"""Simulating a function that queries and returns a completion values"""
return actors
@@ -324,6 +325,7 @@ class TabCompleteExample(cmd2.Cmd):
# No subcommand was provided, so call help
self.do_help('media')
+
# This completer is implemented using a single dictionary to look up completion lists for all layers of
# subcommands. For each argument, AutoCompleter will search for completion values from the provided
# arg_choices dict. This requires careful naming of argparse arguments so that there are no unintentional