diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 20:19:02 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 20:19:02 -0500 |
commit | def2bb90533f72ddd4b8909c0160cf643e19f765 (patch) | |
tree | a73848d752e6dd4491f7d4161d77a21e2f170a0f /cmd2.py | |
parent | 65959e43b5c81443058d3f79225163bc7d2814e5 (diff) | |
download | cmd2-git-def2bb90533f72ddd4b8909c0160cf643e19f765.tar.gz |
Documented undocumented commands and removed command aliases.
The out-of-the-box help menu now looks a lot cleaner:
- All redundant command aliases have been removed
(NOTE: They can still be used if self.abbrev is True, which is the default)
- All previously undocumented commands have been documented
- Unit tests and README.rst documentation has been updated to reflect new behavior
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 26 |
1 files changed, 9 insertions, 17 deletions
@@ -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' |