diff options
| -rw-r--r-- | examples/argparse_completion.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/argparse_completion.py b/examples/argparse_completion.py index fa821b77..7350f46c 100644 --- a/examples/argparse_completion.py +++ b/examples/argparse_completion.py @@ -14,6 +14,7 @@ from cmd2 import ( Cmd2ArgumentParser, CompletionError, CompletionItem, + ansi, with_argparser, ) @@ -45,7 +46,9 @@ class ArgparseCompletion(Cmd): # noinspection PyMethodMayBeStatic def choices_completion_item(self) -> List[CompletionItem]: """Return CompletionItem instead of strings. These give more context to what's being tab completed.""" - items = {1: "My item", 2: "Another item", 3: "Yet another item"} + fancy_item = "These things can\ncontain newlines and\n" + fancy_item += ansi.style("styled text!!", fg=ansi.fg.bright_yellow, underline=True) + items = {1: "My item", 2: "Another item", 3: "Yet another item", 4: fancy_item} return [CompletionItem(item_id, description) for item_id, description in items.items()] # noinspection PyMethodMayBeStatic @@ -73,8 +76,6 @@ class ArgparseCompletion(Cmd): # want the entire choices list showing in the usage text for this command. example_parser.add_argument('--choices', choices=food_item_strs, metavar="CHOICE", help="tab complete using choices") - example_parser.add_argument('--choices', choices=food_item_strs, metavar="CHOICE", help="tab complete using choices") - # Tab complete from choices provided by a choices_provider example_parser.add_argument( '--choices_provider', choices_provider=choices_provider, help="tab complete using a choices_provider" |
