Skip to content

Commit

Permalink
Merge pull request #38 from python-cmd2/remove_aliases
Browse files Browse the repository at this point in the history
Remove command aliases, fix a test, fix readme links.
  • Loading branch information
FedericoCeratto committed Feb 6, 2017
2 parents 65959e4 + 3b7000f commit 4a6bcef
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 61 deletions.
19 changes: 5 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@ cmd2
:target: https://travis-ci.org/python-cmd2/cmd2
:alt: Build status

.. image:: https://ci.appveyor.com/api/projects/status/github/python-cmd2/cmd2
.. image:: https://ci.appveyor.com/api/projects/status/github/python-cmd2/cmd2?branch=master
:target: https://ci.appveyor.com/project/FedericoCeratto/cmd2
:alt: Appveyor build status

.. image:: https://readthedocs.org/projects/cmd2/badge/?version=latest
:target: https://cmd2.readthedocs.io

.. image:: https://img.shields.io/pypi/dm/cmd2.svg?style=plastic
:target: https://pypi.python.org/pypi/cmd2/
:alt: Downloads

.. image:: https://img.shields.io/pypi/v/cmd2.svg?style=plastic
.. image:: https://img.shields.io/pypi/v/cmd2.svg
:target: https://pypi.python.org/pypi/cmd2/
:alt: Latest Version

.. image:: https://img.shields.io/github/license/python-cmd2/cmd2.svg?style=plastic
.. image:: https://img.shields.io/pypi/l/cmd2.svg
:target: https://pypi.python.org/pypi/cmd2/
:alt: License

Expand Down Expand Up @@ -148,13 +144,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.
Expand Down
26 changes: 9 additions & 17 deletions cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -548,6 +548,7 @@ def do_cmdenvironment(self, args):
})

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:
Expand Down Expand Up @@ -1056,10 +1057,12 @@ def _cmdloop(self, intro=None):
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? '):
Expand Down Expand Up @@ -1249,8 +1252,8 @@ def do_list(self, arg):
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
Expand All @@ -1275,7 +1278,7 @@ def do_ed(self, arg):
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") +
Expand Down Expand Up @@ -1337,7 +1340,7 @@ def do__relative_load(self, arg=None):
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\\./]+)')

Expand Down Expand Up @@ -1408,17 +1411,6 @@ def cmdloop(self, intro=None):
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'
Expand Down
9 changes: 2 additions & 7 deletions example/exampleSession.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 2 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
# 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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 74")
else:
expected = normalize("1 5 20")
expected = normalize("1 11 66")

assert out[0].strip() == expected[0].strip()

Expand Down
9 changes: 2 additions & 7 deletions tests/test_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 2 additions & 7 deletions tests/transcript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4a6bcef

Please sign in to comment.