summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-05-29 22:54:28 -0400
committerGitHub <noreply@github.com>2017-05-29 22:54:28 -0400
commit387eaa2b4c98b2e986b24736ee4404f67921b2ef (patch)
tree8c53d0ff6be7ba80921d7cf5b0044b86c610c5eb /cmd2.py
parent8c9d7528256f82c64591c5b70e7e9dab5c3c1417 (diff)
parent6976791a649142df65e167137dda0bd12e1da4a2 (diff)
downloadcmd2-git-387eaa2b4c98b2e986b24736ee4404f67921b2ef.tar.gz
Merge pull request #108 from python-cmd2/remove_parseline
Remove parseline
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index 412204f1..56f8df61 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -548,7 +548,8 @@ def replace_with_file_contents(fname):
"""
if fname:
try:
- result = open(os.path.expanduser(fname[0])).read()
+ with open(os.path.expanduser(fname[0])) as source_file:
+ result = source_file.read()
except IOError:
result = '< %s' % fname[0] # wasn't a file after all
else:
@@ -883,6 +884,10 @@ class Cmd(cmd.Cmd):
def parseline(self, line):
"""Parse the line into a command name and a string containing the arguments.
+ NOTE: This is an override of a parent class method. It is only used by other parent class methods. But
+ we do need to override it here so that the additional shortcuts present in cmd2 get properly expanded for
+ purposes of tab completion.
+
Used for command tab completion. Returns a tuple containing (command, args, line).
'command' and 'args' may be None if the line couldn't be parsed.
@@ -1882,7 +1887,7 @@ relative to the already-running script's directory.
self.perror('Problem accessing script from %s: \n%s' % (targetname, e))
return
keepstate = Statekeeper(self, ('stdin', 'use_rawinput', 'prompt',
- 'continuation_prompt', 'current_script_dir'))
+ 'continuation_prompt', '_current_script_dir'))
self.stdin = target
self.use_rawinput = False
self.prompt = self.continuation_prompt = ''