Skip to content

Commit 6ec2af3

Browse files
authored
Merge pull request #554 from python-cmd2/cleanup
Small refactoring
2 parents 61d5703 + ee4c2d8 commit 6ec2af3

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.9.5 (September TBD, 2018)
1+
## 0.9.5 (October TBD, 2018)
22
* Bug Fixes
33
* Fixed bug where ``get_all_commands`` could return non-callable attributes
44
* Fixed bug where **alias** command was dropping quotes around arguments

cmd2/cmd2.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,13 +2216,11 @@ def alias_create(self, args: argparse.Namespace):
22162216
args.name = utils.strip_quotes(args.name)
22172217
valid, errmsg = self.statement_parser.is_valid_command(args.name)
22182218
if not valid:
2219-
errmsg = "Invalid alias name: {}".format(errmsg)
2220-
self.perror(errmsg, traceback_war=False)
2219+
self.perror("Invalid alias name: {}".format(errmsg), traceback_war=False)
22212220
return
22222221

22232222
if args.name in self.macros:
2224-
errmsg = "Alias cannot have the same name as a macro"
2225-
self.perror(errmsg, traceback_war=False)
2223+
self.perror("Alias cannot have the same name as a macro", traceback_war=False)
22262224
return
22272225

22282226
utils.unquote_redirection_tokens(args.command_args)
@@ -2353,18 +2351,15 @@ def macro_create(self, args: argparse.Namespace):
23532351
args.name = utils.strip_quotes(args.name)
23542352
valid, errmsg = self.statement_parser.is_valid_command(args.name)
23552353
if not valid:
2356-
errmsg = "Invalid macro name: {}".format(errmsg)
2357-
self.perror(errmsg, traceback_war=False)
2354+
self.perror("Invalid macro name: {}".format(errmsg), traceback_war=False)
23582355
return
23592356

23602357
if args.name in self.get_all_commands():
2361-
errmsg = "Macro cannot have the same name as a command"
2362-
self.perror(errmsg, traceback_war=False)
2358+
self.perror("Macro cannot have the same name as a command", traceback_war=False)
23632359
return
23642360

23652361
if args.name in self.aliases:
2366-
errmsg = "Macro cannot have the same name as an alias"
2367-
self.perror(errmsg, traceback_war=False)
2362+
self.perror("Macro cannot have the same name as an alias", traceback_war=False)
23682363
return
23692364

23702365
utils.unquote_redirection_tokens(args.command_args)

0 commit comments

Comments
 (0)