|
31 | 31 | # setting is True |
32 | 32 | import argparse |
33 | 33 | import cmd |
34 | | -import collections |
35 | 34 | import glob |
36 | 35 | import inspect |
37 | 36 | import os |
@@ -328,7 +327,6 @@ class Cmd(cmd.Cmd): |
328 | 327 | timing = False # Prints elapsed time for each command |
329 | 328 |
|
330 | 329 | # To make an attribute settable with the "do_set" command, add it to this ... |
331 | | - # This starts out as a dictionary but gets converted to an OrderedDict sorted alphabetically by key |
332 | 330 | settable = {'colors': 'Allow colorized output (valid values: Terminal, Always, Never)', |
333 | 331 | 'continuation_prompt': 'On 2nd+ line of input', |
334 | 332 | 'debug': 'Show full error stack on error', |
@@ -539,13 +537,10 @@ def visible_prompt(self) -> str: |
539 | 537 | return utils.strip_ansi(self.prompt) |
540 | 538 |
|
541 | 539 | def _finalize_app_parameters(self) -> None: |
542 | | - """Finalize the shortcuts and settable parameters.""" |
| 540 | + """Finalize the shortcuts""" |
543 | 541 | # noinspection PyUnresolvedReferences |
544 | 542 | self.shortcuts = sorted(self.shortcuts.items(), reverse=True) |
545 | 543 |
|
546 | | - # Make sure settable parameters are sorted alphabetically by key |
547 | | - self.settable = collections.OrderedDict(sorted(self.settable.items(), key=lambda t: t[0])) |
548 | | - |
549 | 544 | def decolorized_write(self, fileobj: IO, msg: str) -> None: |
550 | 545 | """Write a string to a fileobject, stripping ANSI escape sequences if necessary |
551 | 546 |
|
@@ -1581,13 +1576,17 @@ def get_visible_commands(self) -> List[str]: |
1581 | 1576 | return commands |
1582 | 1577 |
|
1583 | 1578 | def get_alias_names(self) -> List[str]: |
1584 | | - """Return a list of alias names.""" |
| 1579 | + """Return list of current alias names""" |
1585 | 1580 | return list(self.aliases) |
1586 | 1581 |
|
1587 | 1582 | def get_macro_names(self) -> List[str]: |
1588 | | - """Return a list of macro names.""" |
| 1583 | + """Return list of current macro names""" |
1589 | 1584 | return list(self.macros) |
1590 | 1585 |
|
| 1586 | + def get_settable_names(self) -> List[str]: |
| 1587 | + """Return list of current settable names""" |
| 1588 | + return list(self.settable) |
| 1589 | + |
1591 | 1590 | def get_commands_aliases_and_macros_for_completion(self) -> List[str]: |
1592 | 1591 | """Return a list of visible commands, aliases, and macros for tab completion""" |
1593 | 1592 | visible_commands = set(self.get_visible_commands()) |
@@ -2814,7 +2813,7 @@ def show(self, args: argparse.Namespace, parameter: str='') -> None: |
2814 | 2813 | set_parser.add_argument('-a', '--all', action='store_true', help='display read-only settings as well') |
2815 | 2814 | set_parser.add_argument('-l', '--long', action='store_true', help='describe function of parameter') |
2816 | 2815 | setattr(set_parser.add_argument('param', nargs='?', help='parameter to set or view'), |
2817 | | - ACTION_ARG_CHOICES, settable) |
| 2816 | + ACTION_ARG_CHOICES, get_settable_names) |
2818 | 2817 | set_parser.add_argument('value', nargs='?', help='the new value for settable') |
2819 | 2818 |
|
2820 | 2819 | @with_argparser(set_parser) |
|
0 commit comments