summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 12:37:38 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-04 12:37:38 -0500
commit71d7465c570ea98f6df4ca6b4e88f10c77f4eba0 (patch)
tree859de63a1a8a35ea42f951a8002f07382773398e /cmd2.py
parentb4379b6cc54f263d2f56128dcbd7cd896c386e74 (diff)
downloadcmd2-git-71d7465c570ea98f6df4ca6b4e88f10c77f4eba0.tar.gz
Added more and better unit tests for load and save commands
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 85f9b752..537c28b1 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -531,7 +531,8 @@ class Cmd(cmd.Cmd):
if sys.platform[:3] == 'win':
editor = 'notepad'
else:
- for editor in ['gedit', 'kate', 'vim', 'vi', 'emacs', 'nano', 'pico']:
+ # Favor command-line editors first so we don't leave the terminal to edit
+ for editor in ['vim', 'vi', 'emacs', 'nano', 'pico', 'gedit', 'kate', 'subl', 'geany', 'atom']:
if _which(editor):
break
@@ -1332,7 +1333,8 @@ class Cmd(cmd.Cmd):
elif args.idx:
saveme = self.history[int(args.idx) - 1]
else:
- saveme = self.history[-1]
+ # Since this save command has already been added to history, need to go one more back for previous
+ saveme = self.history[-2]
try:
f = open(os.path.expanduser(fname), 'w')
f.write(saveme)
@@ -1374,7 +1376,8 @@ class Cmd(cmd.Cmd):
def do_load(self, arg=None):
"""Runs script of command(s) from a file or URL."""
- if arg is None:
+ # If arg is None or arg is an empty string, use the default filename
+ if not arg:
targetname = self.default_file_name
else:
arg = arg.split(None, 1)