summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-06 11:28:05 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-06 11:28:05 -0400
commit67445d49af8db72f9e27a8d47449d0b5ed1e6b9c (patch)
tree01037014c93fd5b72bb5498b94369876c5238c4b /cmd2/cmd2.py
parent5ef4267360e87d8c2af13d0b7f6a6cd8d80fd016 (diff)
downloadcmd2-git-67445d49af8db72f9e27a8d47449d0b5ed1e6b9c.tar.gz
Display set command tab-completion results as CompletionItems
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 364f18f9..46d996ea 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1606,16 +1606,16 @@ class Cmd(cmd.Cmd):
return commands
def _get_alias_completion_items(self) -> List[CompletionItem]:
- """Return list of current alias names"""
+ """Return list of current alias names and values as CompletionItems"""
return [CompletionItem(cur_key, self.aliases[cur_key]) for cur_key in self.aliases]
def _get_macro_completion_items(self) -> List[CompletionItem]:
- """Return list of current alias names"""
+ """Return list of current macro names and values as CompletionItems"""
return [CompletionItem(cur_key, self.macros[cur_key].value) for cur_key in self.macros]
- def _get_settable_names(self) -> List[str]:
- """Return list of current settable names"""
- return list(self.settable)
+ def _get_settable_completion_items(self) -> List[CompletionItem]:
+ """Return list of current settable names and descriptions as CompletionItems"""
+ return [CompletionItem(cur_key, self.settable[cur_key]) for cur_key in self.settable]
def _get_commands_aliases_and_macros_for_completion(self) -> List[str]:
"""Return a list of visible commands, aliases, and macros for tab completion"""
@@ -2920,7 +2920,7 @@ class Cmd(cmd.Cmd):
set_parser.add_argument('-a', '--all', action='store_true', help='display read-only settings as well')
set_parser.add_argument('-l', '--long', action='store_true', help='describe function of parameter')
set_parser.add_argument('param', nargs=argparse.OPTIONAL, help='parameter to set or view',
- choices_method=_get_settable_names)
+ choices_method=_get_settable_completion_items, descriptive_header='Description')
set_parser.add_argument('value', nargs=argparse.OPTIONAL, help='the new value for settable')
@with_argparser(set_parser)