diff options
-rwxr-xr-x | README.rst | 9 | ||||
-rwxr-xr-x | cmd2.py | 26 | ||||
-rw-r--r-- | example/exampleSession.txt | 9 | ||||
-rw-r--r-- | tests/conftest.py | 9 | ||||
-rw-r--r-- | tests/test_cmd2.py | 4 | ||||
-rw-r--r-- | tests/test_transcript.py | 9 | ||||
-rw-r--r-- | tests/transcript.txt | 9 |
7 files changed, 21 insertions, 54 deletions
@@ -148,13 +148,8 @@ example/exampleSession.txt:: Documented commands (type help <topic>):
========================================
- _load ed history list pause run set show
- _relative_load edit l load py save shell speak
- cmdenvironment hi li orate r say shortcuts
-
- Undocumented commands:
- ======================
- EOF eof exit help q quit
+ _relative_load edit help list orate py run say shell show
+ cmdenvironment eof history load pause quit save set shortcuts speak
(Cmd) help say
Repeats what you tell me to.
@@ -4,7 +4,7 @@ To use, simply import cmd2.Cmd instead of cmd.Cmd; use precisely as though you were using the standard library's cmd, while enjoying the extra features. -Searchable command history (commands: "hi", "li", "run") +Searchable command history (commands: "history", "list", "run") Load commands from file, save to file, edit commands in file Multi-line commands Case-insensitive commands @@ -548,6 +548,7 @@ class Cmd(cmd.Cmd): }) def do_help(self, arg): + '''List available commands with "help" or detailed help with "help cmd".''' if arg: funcname = self.func_named(arg) if funcname: @@ -1056,10 +1057,12 @@ class Cmd(cmd.Cmd): pass return stop - def do_EOF(self, arg): + def do_eof(self, arg): + """Automatically called at end of loading a script.""" return self._STOP_SCRIPT_NO_EXIT # End of script; should not exit app def do_quit(self, arg): + """Exits this application.""" return self._STOP_AND_EXIT def select(self, options, prompt='Your choice? '): @@ -1249,8 +1252,8 @@ class Cmd(cmd.Cmd): for hi in history: self.poutput(hi.pr()) - def do_ed(self, arg): - """ed: edit most recent command in text editor + def do_edit(self, arg): + """edit: edit most recent command in text editor ed [N]: edit numbered command from history ed [filename]: edit specified file name @@ -1275,7 +1278,7 @@ class Cmd(cmd.Cmd): f.close() os.system('%s %s' % (self.editor, filename)) - self.do__load(filename) + self.do_load(filename) saveparser = (pyparsing.Optional(pyparsing.Word(pyparsing.nums) ^ '*')("idx") + pyparsing.Optional(pyparsing.Word(legalChars + '/\\'))("fname") + @@ -1337,7 +1340,7 @@ class Cmd(cmd.Cmd): arg = arg.split(None, 1) targetname, args = arg[0], (arg[1:] or [''])[0] targetname = os.path.join(self.current_script_dir or '', targetname) - self.do__load('%s %s' % (targetname, args)) + self.do_load('%s %s' % (targetname, args)) urlre = re.compile('(https?://[-\\w\\./]+)') @@ -1408,17 +1411,6 @@ class Cmd(cmd.Cmd): if not self.run_commands_at_invocation(callargs): self._cmdloop() - # Command Aliases - do_eof = do_EOF - do_exit = do_quit - do_q = do_quit - do_hi = do_history - do_l = do_list - do_li = do_list - do_edit = do_ed - do__load = do_load # avoid an unfortunate legacy use of do_load from sqlpython - do_r = do_run - class HistoryItem(str): listformat = '-------------------------[%d]\n%s\n' diff --git a/example/exampleSession.txt b/example/exampleSession.txt index 945ea0bc..a4eef91f 100644 --- a/example/exampleSession.txt +++ b/example/exampleSession.txt @@ -2,13 +2,8 @@ Documented commands (type help <topic>): ======================================== -_load ed history list pause run set show -_relative_load edit l load py save shell speak -cmdenvironment hi li orate r say shortcuts - -Undocumented commands: -====================== -EOF eof exit help q quit +_relative_load edit help list orate py run say shell show +cmdenvironment eof history load pause quit save set shortcuts speak (Cmd) help say Repeats what you tell me to. diff --git a/tests/conftest.py b/tests/conftest.py index 7bbefd6d..530c70a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,13 +14,8 @@ import cmd2 # Help text for base cmd2.Cmd application BASE_HELP = """Documented commands (type help <topic>): ======================================== -_load ed history list py save shortcuts -_relative_load edit l load r set show -cmdenvironment hi li pause run shell - -Undocumented commands: -====================== -EOF eof exit help q quit +_relative_load edit help list pause quit save shell show +cmdenvironment eof history load py run set shortcuts """ # Help text for the history command diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 33c4acb3..e88c4c18 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -346,9 +346,9 @@ def test_pipe_to_shell(base_app): out = run_cmd(base_app, 'help help | wc') if sys.platform == "win32": - expected = normalize("1 5 24") + expected = normalize("1 11 70") else: - expected = normalize("1 5 20") + expected = normalize("1 11 66") assert out[0].strip() == expected[0].strip() diff --git a/tests/test_transcript.py b/tests/test_transcript.py index aeadae4e..d699f545 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -105,13 +105,8 @@ def test_base_with_transcript(_cmdline_app): Documented commands (type help <topic>): ======================================== -_load ed history list pause run set show -_relative_load edit l load py save shell speak -cmdenvironment hi li orate r say shortcuts - -Undocumented commands: -====================== -EOF eof exit help q quit +_relative_load edit help list orate py run say shell show +cmdenvironment eof history load pause quit save set shortcuts speak (Cmd) help say Repeats what you tell me to. diff --git a/tests/transcript.txt b/tests/transcript.txt index 91f27dff..1e10ee31 100644 --- a/tests/transcript.txt +++ b/tests/transcript.txt @@ -2,13 +2,8 @@ Documented commands (type help <topic>): ======================================== -_load ed history list pause run set show -_relative_load edit l load py save shell speak -cmdenvironment hi li orate r say shortcuts - -Undocumented commands: -====================== -EOF eof exit help q quit +_relative_load edit help list orate py run say shell show +cmdenvironment eof history load pause quit save set shortcuts speak (Cmd) help say Repeats what you tell me to. |