|
14 | 14 | Cmd2ArgumentParser, |
15 | 15 | CompletionError, |
16 | 16 | CompletionItem, |
| 17 | + ansi, |
17 | 18 | with_argparser, |
18 | 19 | ) |
19 | 20 |
|
@@ -45,7 +46,9 @@ def choices_completion_error(self) -> List[str]: |
45 | 46 | # noinspection PyMethodMayBeStatic |
46 | 47 | def choices_completion_item(self) -> List[CompletionItem]: |
47 | 48 | """Return CompletionItem instead of strings. These give more context to what's being tab completed.""" |
48 | | - items = {1: "My item", 2: "Another item", 3: "Yet another item"} |
| 49 | + fancy_item = "These things can\ncontain newlines and\n" |
| 50 | + fancy_item += ansi.style("styled text!!", fg=ansi.fg.bright_yellow, underline=True) |
| 51 | + items = {1: "My item", 2: "Another item", 3: "Yet another item", 4: fancy_item} |
49 | 52 | return [CompletionItem(item_id, description) for item_id, description in items.items()] |
50 | 53 |
|
51 | 54 | # noinspection PyMethodMayBeStatic |
@@ -73,8 +76,6 @@ def choices_arg_tokens(self, arg_tokens: Dict[str, List[str]]) -> List[str]: |
73 | 76 | # want the entire choices list showing in the usage text for this command. |
74 | 77 | example_parser.add_argument('--choices', choices=food_item_strs, metavar="CHOICE", help="tab complete using choices") |
75 | 78 |
|
76 | | - example_parser.add_argument('--choices', choices=food_item_strs, metavar="CHOICE", help="tab complete using choices") |
77 | | - |
78 | 79 | # Tab complete from choices provided by a choices_provider |
79 | 80 | example_parser.add_argument( |
80 | 81 | '--choices_provider', choices_provider=choices_provider, help="tab complete using a choices_provider" |
|
0 commit comments