summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-08-22 17:45:34 -0700
committerGitHub <noreply@github.com>2017-08-22 17:45:34 -0700
commitd5f91bd490aac11180644c5549dc340826901fb2 (patch)
treed44878dbf9f33261e3022e7a057e65ba540848e9 /cmd2.py
parent6ff0def7c35a29031ac3ca7e8ba580e971633c6c (diff)
parent3a842abbd2e6511b2721ead634c14b076ac3b362 (diff)
downloadcmd2-git-d5f91bd490aac11180644c5549dc340826901fb2.tar.gz
Merge branch 'master' into fix/transcript_regexes
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/cmd2.py b/cmd2.py
index 68ede281..f4eb3b00 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1589,13 +1589,11 @@ Paths or arguments that contain spaces must be enclosed in quotes
except IndexError:
return None
- def do_edit(self, arg):
- """Edit a file or command in a text editor.
-
- Usage: edit [N]|[file_path]
-
+ @options([], arg_desc="""[N]|[file_path]
* N - Number of command (from history), or `*` for all commands in history (default: last command)
- * file_path - path to a file to open in editor
+ * file_path - path to a file to open in editor""")
+ def do_edit(self, arg, opts=None):
+ """Edit a file or command in a text editor.
The editor used is determined by the ``editor`` settable parameter.
"set editor (program-name)" to change or set the EDITOR environment variable.
@@ -1605,15 +1603,16 @@ If neither is supplied, the most recent command in the history is edited.
Edited commands are always run after the editor is closed.
-Edited files are run on close if the ``autorun_on_edit`` settable parameter is True."""
+Edited files are run on close if the ``autorun_on_edit`` settable parameter is True.
+"""
if not self.editor:
raise EnvironmentError("Please use 'set editor' to specify your text editing program of choice.")
filename = None
- if arg:
+ if arg and arg[0]:
try:
- history_item = self._last_matching(int(arg))
+ history_item = self._last_matching(int(arg[0]))
except ValueError:
- filename = arg
+ filename = arg[0]
history_item = ''
else:
try: