diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 19:20:24 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 19:20:24 -0400 |
commit | 75f0ae0b0beb47495e6f45a193f68a9c49357648 (patch) | |
tree | c52a008cd4fab1481d4c2f32634fbbc84aa4dcbe /cmd2 | |
parent | e2e446df83e8809062ff42bff05a2dd8bc5df9ab (diff) | |
download | cmd2-git-75f0ae0b0beb47495e6f45a193f68a9c49357648.tar.gz |
Changes requested in code review
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/cmd2.py | 12 | ||||
-rw-r--r-- | cmd2/parsing.py | 2 |
2 files changed, 3 insertions, 11 deletions
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) |