diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | cmd2/cmd2.py | 12 | ||||
-rw-r--r-- | cmd2/parsing.py | 2 |
3 files changed, 4 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e93f9ff9..0f4283cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ * Added ``macro`` command to create macros, which are similar to aliases, but can take arguments when called * ``alias`` is now an argparse command with subcommands to create, list, and delete aliases * Deprecations - * Deprecated the builtin ``cmd2`` support for colors including ``Cmd.colorize()`` and ``Cmd._colorcodes`` + * Deprecated the built-in ``cmd2`` support for colors including ``Cmd.colorize()`` and ``Cmd._colorcodes`` * `unalias` is no longer a command since ``alias delete`` replaced it * Deletions * The ``preparse``, ``postparsing_precmd``, and ``postparsing_postcmd`` methods *deprecated* in the previous release diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 685bf165..09fec115 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1618,12 +1618,6 @@ class Cmd(cmd.Cmd): """Return a list of macro names.""" return list(self.macros) - def get_commands_and_aliases_for_completion(self) -> List[str]: - """Return a list of visible commands and aliases for tab completion""" - visible_commands = set(self.get_visible_commands()) - alias_names = set(self.get_alias_names()) - return list(visible_commands | alias_names) - def get_commands_aliases_and_macros_for_completion(self) -> List[str]: """Return a list of visible commands, aliases, and macros for tab completion""" visible_commands = set(self.get_visible_commands()) @@ -2339,8 +2333,7 @@ class Cmd(cmd.Cmd): alias_create_parser = alias_subparsers.add_parser('create', help=alias_create_help, description=alias_create_description, epilog=alias_create_epilog) - setattr(alias_create_parser.add_argument('name', help='name of this alias'), - ACTION_ARG_CHOICES, get_commands_and_aliases_for_completion) + alias_create_parser.add_argument('name', help='name of this alias') setattr(alias_create_parser.add_argument('command', help='what the alias resolves to'), ACTION_ARG_CHOICES, get_commands_aliases_and_macros_for_completion) setattr(alias_create_parser.add_argument('command_args', nargs=argparse.REMAINDER, @@ -2552,8 +2545,7 @@ class Cmd(cmd.Cmd): macro_create_parser = macro_subparsers.add_parser('create', help=macro_create_help, description=macro_create_description, epilog=macro_create_epilog) - setattr(macro_create_parser.add_argument('name', help='name of this macro'), - ACTION_ARG_CHOICES, get_macro_names) + macro_create_parser.add_argument('name', help='name of this macro') setattr(macro_create_parser.add_argument('command', help='what the macro resolves to'), ACTION_ARG_CHOICES, get_commands_aliases_and_macros_for_completion) setattr(macro_create_parser.add_argument('command_args', nargs=argparse.REMAINDER, diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 9b86b487..27d17d21 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -59,7 +59,7 @@ class Macro: required_arg_count = attr.ib(validator=attr.validators.instance_of(int)) # Used to fill in argument placeholders in the macro - arg_list = attr.ib(factory=list, validator=attr.validators.instance_of(list)) + arg_list = attr.ib(default=attr.Factory(list), validator=attr.validators.instance_of(list)) @attr.s(frozen=True) |