@@ -139,7 +139,7 @@ def my_completer(self, text, line, begidx, endidx, arg_tokens)
139139that value's name. The right column header is defined using the
140140``descriptive_headers`` parameter of add_argument(), which is a list of header
141141names that defaults to ["Description"]. The right column values come from the
142- ``CompletionItem.descriptive_data `` member, which is a list with the same number
142+ ``CompletionItem.description `` member, which is a list with the same number
143143of items as columns defined in descriptive_headers.
144144
145145To use CompletionItems, just return them from your choices_provider or
@@ -166,7 +166,7 @@ def my_completer(self, text, line, begidx, endidx, arg_tokens)
166166 def get_items(self) -> list[CompletionItems]:
167167 \" \" \" choices_provider which returns CompletionItems\" \" \"
168168
169- # CompletionItem's second argument is descriptive_data .
169+ # CompletionItem's second argument is description .
170170 # Its item count should match that of descriptive_headers.
171171 return [
172172 CompletionItem(1, ["My item", True, "02/02/2022"]),
@@ -194,14 +194,14 @@ def get_items(self) -> list[CompletionItems]:
194194truncated with an ellipsis at the end. You can override this and other settings
195195when you create the ``Column``.
196196
197- ``descriptive_data `` items can include Rich objects, including styled Text and Tables.
197+ ``description `` items can include Rich objects, including styled Text and Tables.
198198
199199To avoid printing a excessive information to the screen at once when a user
200200presses tab, there is a maximum threshold for the number of CompletionItems
201201that will be shown. Its value is defined in ``cmd2.Cmd.max_completion_items``.
202202It defaults to 50, but can be changed. If the number of completion suggestions
203203exceeds this number, they will be displayed in the typical columnized format
204- and will not include the descriptive_data of the CompletionItems.
204+ and will not include the description of the CompletionItems.
205205
206206
207207**Patched argparse functions**
@@ -384,22 +384,26 @@ def __new__(cls, value: object, *_args: Any, **_kwargs: Any) -> 'CompletionItem'
384384 """Responsible for creating and returning a new instance, called before __init__ when an object is instantiated."""
385385 return super ().__new__ (cls , value )
386386
387- def __init__ (self , value : object , descriptive_data : Sequence [Any ], * args : Any ) -> None :
387+ def __init__ (self , value : object , description : str | Sequence [Any ], * args : Any ) -> None :
388388 """CompletionItem Initializer.
389389
390390 :param value: the value being tab completed
391- :param descriptive_data : a list of descriptive data to display in the columns that follow
392- the completion value. The number of items in this list must equal
391+ :param description : a string or list of descriptive data to display in the columns that follow
392+ the completion value. If a list, the number of items in this list must equal
393393 the number of descriptive headers defined for the argument.
394394 :param args: args for str __init__
395395 """
396396 super ().__init__ (* args )
397397
398+ # If description is a string, wrap it in a list
399+ if isinstance (description , str ):
400+ description = [description ]
401+
398402 # Make sure all objects are renderable by a Rich table.
399- renderable_data = [obj if is_renderable (obj ) else str (obj ) for obj in descriptive_data ]
403+ renderable_data = [obj if is_renderable (obj ) else str (obj ) for obj in description ]
400404
401405 # Convert strings containing ANSI style sequences to Rich Text objects for correct display width.
402- self .descriptive_data = ru .prepare_objects_for_rendering (* renderable_data )
406+ self .description = ru .prepare_objects_for_rendering (* renderable_data )
403407
404408 # Save the original value to support CompletionItems as argparse choices.
405409 # cmd2 has patched argparse so input is compared to this value instead of the CompletionItem instance.
0 commit comments