From 5027f7cbcf2575dfc5a0c67068951c9ea4b9d7dd Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 8 Nov 2017 13:38:14 -0500 Subject: Added fix for changes in pyperclip project structure in the most recent version Also included a number of minor maintenance updates: - Bumped version to 0.7.8 in preparation for upcoming release - Updated Readme.md to add link to slides from recent Florida PyCon talk about cmd2 - Updated documentation on integrating cmd2 with other event loops to use newer runcmds_plus_hooks() method instead of legacy onecmds_plus_hooks method which doesn't properly deal with load commands - Deleted old files which were used to prepare for a PyCon 2010 presentation - Updated ChangeLog regarding this bug fix --- docs/conf.py | 2 +- docs/index.rst | 6 +- docs/integrating.rst | 12 +- docs/pycon2010/akkad.png | Bin 57996 -> 0 bytes docs/pycon2010/apple.jpg | Bin 72215 -> 0 bytes docs/pycon2010/hook.jpg | Bin 52555 -> 0 bytes docs/pycon2010/pirate.py | 10 - docs/pycon2010/pirate2.py | 24 --- docs/pycon2010/pirate3.py | 30 --- docs/pycon2010/pirate4.py | 36 ---- docs/pycon2010/pirate5.py | 45 ----- docs/pycon2010/pirate6.py | 50 ----- docs/pycon2010/pirate7.py | 59 ------ docs/pycon2010/pirate8.py | 71 -------- docs/pycon2010/pycon2010.rst | 382 --------------------------------------- docs/pycon2010/sargon.jpg | Bin 17452 -> 0 bytes docs/pycon2010/schematic.png | Bin 8966 -> 0 bytes docs/pycon2010/script.txt | 5 - docs/pycon2010/strategy.png | Bin 29460 -> 0 bytes docs/pycon2010/transcript.txt | 12 -- docs/pycon2010/urwid.png | Bin 40788 -> 0 bytes docs/pycon2010/web-2-0-logos.gif | Bin 55776 -> 0 bytes 22 files changed, 15 insertions(+), 729 deletions(-) delete mode 100644 docs/pycon2010/akkad.png delete mode 100644 docs/pycon2010/apple.jpg delete mode 100644 docs/pycon2010/hook.jpg delete mode 100644 docs/pycon2010/pirate.py delete mode 100644 docs/pycon2010/pirate2.py delete mode 100644 docs/pycon2010/pirate3.py delete mode 100644 docs/pycon2010/pirate4.py delete mode 100644 docs/pycon2010/pirate5.py delete mode 100644 docs/pycon2010/pirate6.py delete mode 100644 docs/pycon2010/pirate7.py delete mode 100644 docs/pycon2010/pirate8.py delete mode 100644 docs/pycon2010/pycon2010.rst delete mode 100644 docs/pycon2010/sargon.jpg delete mode 100644 docs/pycon2010/schematic.png delete mode 100644 docs/pycon2010/script.txt delete mode 100644 docs/pycon2010/strategy.png delete mode 100644 docs/pycon2010/transcript.txt delete mode 100644 docs/pycon2010/urwid.png delete mode 100644 docs/pycon2010/web-2-0-logos.gif (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index f79d5b3c..1212a6e2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -62,7 +62,7 @@ author = 'Catherine Devlin and Todd Leonhardt' # The short X.Y version. version = '0.7' # The full version, including alpha/beta/rc tags. -release = '0.7.7' +release = '0.7.8' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 1f2bf96c..d84558af 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -46,9 +46,9 @@ Resources * cmd_ * `cmd2 project page`_ * `project bug tracker`_ -* `PyCon 2010 presentation `_, - *Easy Command-Line Applications with cmd and cmd2*: - :doc:`slides `, +* Florida PyCon 2017: `slides `_ +* PyOhio 2011: `video `_ +* PyCon 2010: `presentation `_, `video `_ These docs will refer to ``App`` as your ``cmd2.Cmd`` diff --git a/docs/integrating.rst b/docs/integrating.rst index 32ab37e0..bcb9301c 100644 --- a/docs/integrating.rst +++ b/docs/integrating.rst @@ -46,10 +46,14 @@ code like the following:: # Do this within whatever event loop mechanism you wish to run a single command cmd_line_text = "help history" - app.onecmd_plus_hooks(cmd_line_text) + app.runcmds_plus_hooks([cmd_line_text]) app.postloop() +The **runcmds_plus_hooks()** method is a convenience method to run multiple commands via **onecmd_plus_hooks()**. It +properly deals with ``load`` commands which under the hood put commands in a FIFO queue as it reads them in from a +script file. + The **onecmd_plus_hooks()** method will do the following to execute a single ``cmd2`` command in a normal fashion: #. Parse the command line text @@ -70,4 +74,10 @@ several disadvantages, including: * Does not support transcript testing * Does not allow commands at invocation via command-line arguments +Here is a little more info on ``runcmds_plus_hooks``: + +.. automethod:: cmd2.Cmd.runcmds_plus_hooks + + + diff --git a/docs/pycon2010/akkad.png b/docs/pycon2010/akkad.png deleted file mode 100644 index 57799e97..00000000 Binary files a/docs/pycon2010/akkad.png and /dev/null differ diff --git a/docs/pycon2010/apple.jpg b/docs/pycon2010/apple.jpg deleted file mode 100644 index 2148af3b..00000000 Binary files a/docs/pycon2010/apple.jpg and /dev/null differ diff --git a/docs/pycon2010/hook.jpg b/docs/pycon2010/hook.jpg deleted file mode 100644 index 819370d0..00000000 Binary files a/docs/pycon2010/hook.jpg and /dev/null differ diff --git a/docs/pycon2010/pirate.py b/docs/pycon2010/pirate.py deleted file mode 100644 index bd8b5170..00000000 --- a/docs/pycon2010/pirate.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -from cmd import Cmd - - -class Pirate(Cmd): - pass - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate2.py b/docs/pycon2010/pirate2.py deleted file mode 100644 index 343f94ff..00000000 --- a/docs/pycon2010/pirate2.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from cmd import Cmd - - -# using ``do_`` methods - -class Pirate(Cmd): - gold = 3 - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - print('Now we gots {0} doubloons' - .format(self.gold)) - - def do_drink(self, arg): - 'Drown your sorrrows in rrrum.' - self.gold -= 1 - print('Now we gots {0} doubloons' - .format(self.gold)) - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate3.py b/docs/pycon2010/pirate3.py deleted file mode 100644 index 46f26501..00000000 --- a/docs/pycon2010/pirate3.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding=utf-8 -from cmd import Cmd - - -# using hook - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - 'Drown your sorrrows in rrrum.' - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate4.py b/docs/pycon2010/pirate4.py deleted file mode 100644 index ae1e1f4b..00000000 --- a/docs/pycon2010/pirate4.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -from cmd import Cmd - - -# using arguments - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons'.format(self.gold)) - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate5.py b/docs/pycon2010/pirate5.py deleted file mode 100644 index 68da88a5..00000000 --- a/docs/pycon2010/pirate5.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -from cmd import Cmd - - -# quitting - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - if self.gold < 0: - print("Off to debtorrr's prison.") - stop = True - return stop - - def do_quit(self, arg): - print("Quiterrr!") - return True - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate6.py b/docs/pycon2010/pirate6.py deleted file mode 100644 index bd5f5fe2..00000000 --- a/docs/pycon2010/pirate6.py +++ /dev/null @@ -1,50 +0,0 @@ -# coding=utf-8 -from cmd2 import Cmd - - -# prompts and defaults - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - prompt = 'arrr> ' - - def default(self, line): - print('What mean ye by "{0}"?' - .format(line)) - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - if self.gold < 0: - print("Off to debtorrr's prison.") - stop = True - return stop - - def do_quit(self, arg): - print("Quiterrr!") - return True - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate7.py b/docs/pycon2010/pirate7.py deleted file mode 100644 index 799f73ed..00000000 --- a/docs/pycon2010/pirate7.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding=utf-8 -from cmd2 import Cmd - - -# prompts and defaults - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - prompt = 'arrr> ' - - def default(self, line): - print('What mean ye by "{0}"?'.format(line)) - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - if self.gold < 0: - print("Off to debtorrr's prison.") - stop = True - return stop - - def do_quit(self, arg): - print("Quiterrr!") - return True - - default_to_shell = True - multilineCommands = ['sing'] - terminators = Cmd.terminators + ['...'] - songcolor = 'blue' - settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)' - Cmd.shortcuts.update({'~': 'sing'}) - - def do_sing(self, arg): - print(self.colorize(arg, self.songcolor)) - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pirate8.py b/docs/pycon2010/pirate8.py deleted file mode 100644 index 58b56208..00000000 --- a/docs/pycon2010/pirate8.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -from cmd2 import Cmd, options, make_option - - -# prompts and defaults - -class Pirate(Cmd): - gold = 3 - initial_gold = gold - prompt = 'arrr> ' - - def default(self, line): - print('What mean ye by "{0}"?'.format(line)) - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) - self.gold -= 1 - - def precmd(self, line): - self.initial_gold = self.gold - return line - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - if self.gold < 0: - print("Off to debtorrr's prison.") - stop = True - return stop - - def do_quit(self, arg): - print("Quiterrr!") - return True - - default_to_shell = True - multilineCommands = ['sing'] - terminators = Cmd.terminators + ['...'] - songcolor = 'blue' - settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)' - Cmd.shortcuts.update({'~': 'sing'}) - - def do_sing(self, arg): - print(self.colorize(arg, self.songcolor)) - - @options([make_option('--ho', type='int', default=2, - help="How often to chant 'ho'"), - make_option('-c', '--commas', - action="store_true", - help="Intersperse commas")]) - def do_yo(self, arg, opts): - chant = ['yo'] + ['ho'] * opts.ho - separator = ', ' if opts.commas else ' ' - chant = separator.join(chant) - print('{0} and a bottle of {1}' - .format(chant, arg)) - - -pirate = Pirate() -pirate.cmdloop() diff --git a/docs/pycon2010/pycon2010.rst b/docs/pycon2010/pycon2010.rst deleted file mode 100644 index 6c3af676..00000000 --- a/docs/pycon2010/pycon2010.rst +++ /dev/null @@ -1,382 +0,0 @@ -================================================ -Easy command-line interpreters with cmd and cmd2 -================================================ - -:author: Catherine Devlin -:date: 2010-02-20 -:slides: http://pypi.python.org/pypi/cmd2 - -Web 2.0 -======= - -.. image:: web-2-0-logos.gif - :height: 350px - -But first... -============ - -.. image:: sargon.jpg - :height: 250px - -.. image:: akkad.png - :height: 250px - -Sargon the Great - Founder of Akkadian Empire - -.. twenty-third century BC - -In between -========== - -.. image:: apple.jpg - :height: 250px - -Command-Line Interface - Unlike the Akkadian Empire, - the CLI will never die. - -Defining CLI -============ - -Also known as - -- "Line-oriented command interpreter" -- "Command-line interface" -- "Shell" - -1. Accepts free text input at prompt -2. Outputs lines of text -3. (repeat) - -Examples -======== - -.. class:: big - - * Bash, Korn, zsh - * Python shell - * screen - * Zork - * SQL clients: psql, SQL*\Plus, mysql... - * ed - -.. ``ed`` proves that CLI is sometimes the wrong answer. - -!= Command Line Utilities -========================= - -.. class:: big - - (``ls``, ``grep``, ``ping``, etc.) - - 1. Accept arguments at invocation - 2. execute - 3. terminate - - Use ``sys.argv``, ``optparse`` - -!="Text User Interface" -======================= - -* Use entire (session) screen -* I/O is *not* line-by-line -* See ``curses``, ``urwid`` - -.. image:: urwid.png - :height: 250px - - -Decide your priorities -====================== - -.. image:: strategy.png - :height: 350px - -A ``cmd`` app: pirate.py -======================== - -:: - - from cmd import Cmd - - class Pirate(Cmd): - pass - - pirate = Pirate() - pirate.cmdloop() - -.. Nothing here... but history and help - -.. ctrl-r for bash-style history - -Fundamental prrrinciple -======================= - -.. class:: huge - - ``(Cmd) foo a b c`` - - becomes - - ``self.do_foo('a b c')`` - -``do_``-methods: pirate2.py -=========================== - -:: - - class Pirate(Cmd): - gold = 3 - def do_loot(self, arg): - 'Seize booty frrrom a passing ship.' - self.gold += 1 - print('Now we gots {0} doubloons' - .format(self.gold)) - def do_drink(self, arg): - 'Drown your sorrrows in rrrum.' - self.gold -= 1 - print('Now we gots {0} doubloons' - .format(self.gold)) - -.. do_methods; more help - -Hooks -===== - -.. image:: hook.jpg - :height: 250px - -:: - - self.preloop() - self.postloop() - self.precmd(line) - self.postcmd(stop, line) - -Hooks: pirate3.py -================= - -:: - - def do_loot(self, arg): - 'Seize booty from a passing ship.' - self.gold += 1 - def do_drink(self, arg): - 'Drown your sorrrows in rrrum.' - self.gold -= 1 - def precmd(self, line): - self.initial_gold = self.gold - return line - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - -Arguments: pirate4.py -===================== - -:: - - def do_drink(self, arg): - '''Drown your sorrrows in rrrum. - - drink [n] - drink [n] barrel[s] o' rum.''' - try: - self.gold -= int(arg) - except: - if arg: - print('''What's "{0}"? I'll take rrrum.''' - .format(arg)) - self.gold -= 1 - -quitting: pirate5.py -==================== - -:: - - def postcmd(self, stop, line): - if self.gold != self.initial_gold: - print('Now we gots {0} doubloons' - .format(self.gold)) - if self.gold < 0: - print("Off to debtorrr's prison.") - stop = True - return stop - def do_quit(self, arg): - print("Quiterrr!") - return True - -prompts, defaults: pirate6.py -============================= - -:: - - prompt = 'arrr> ' - def default(self, line): - print('What mean ye by "{0}"?' - .format(line)) - -Other CLI packages -================== - -.. class:: big - - * CmdLoop - * cly - * CMdO - * pycopia - * cmdlin - * cmd2 - -Demo -==== - -.. class:: huge - - Convert ``cmd`` app to ``cmd2`` - -cmd2 -==== - -.. image:: schematic.png - :height: 350px - -As you wish, Guido -================== - -.. class:: huge - - Python 3 compatible - -(um, mostly) - -Absolutely free -=============== - -Script files - -Commands at invocation - -Output redirection - -Python - -Transcript testing - -But wait, there's more -====================== - - * Abbreviated commands - * Shell commands - * Quitting - * Timing - * Echo - * Debug - -Minor changes: pirate7.py -========================= - -:: - - default_to_shell = True - multilineCommands = ['sing'] - terminators = Cmd.terminators + ['...'] - songcolor = 'blue' - settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)' - Cmd.shortcuts.update({'~': 'sing'}) - def do_sing(self, arg): - print(self.colorize(arg, self.songcolor)) - -Now how much would you pay? -=========================== - -options / flags - -Quiet (suppress feedback) - -BASH-style ``select`` - -Parsing: terminators, suffixes - -Options: pirate8.py -=================== - -:: - - @options([make_option('--ho', type='int', default=2, - help="How often to chant 'ho'"), - make_option('-c', '--commas', - action="store_true", - help="Intersperse commas")]) - def do_yo(self, arg, opts): - chant = ['yo'] + ['ho'] * opts.ho - separator = ', ' if opts.commas else ' ' - chant = separator.join(chant) - print('{0} and a bottle of {1}' - .format(chant, arg)) - -Serious example: sqlpython -========================== - -.. class:: big - - ``cmd``-based app by Luca Canali @ CERN - - Replacement for Oracle SQL\*Plus - - Now ``cmd2``-based; postgreSQL; MySQL - -File reporter -============= - -.. class:: huge - - Gather info: Python - - Store: postgresql - - Report: html - -fileutil.py -=========== - -:: - - import glob - import os.path - - for fullfilename in glob.glob('/home/cat/proj/cmd2/*.py'): - (dirpath, fname) = os.path.split(fullfilename) - stats = os.stat(fullfilename) - binds['path'] = dirpath - binds['name'] = fname - binds['bytes'] = stats.st_size - cmd("""INSERT INTO cat.files (path, name, bytes) - VALUES (%(path)s, %(name)s, %(bytes)s)""") - quit() - -sqlpython features -================== - -.. class:: big - - * from ``cmd2``: scripts, redirection, - py, etc. - * multiple connections - * UNIX: ls, cat, grep - * Special output - - -Thank you -========= - -.. class:: big - - http://pypi.python.org/pypi/cmd2 - - http://catherinedevlin.blogspot.com - - http://catherinedevlin.pythoneers.com - - diff --git a/docs/pycon2010/sargon.jpg b/docs/pycon2010/sargon.jpg deleted file mode 100644 index 5960f1e0..00000000 Binary files a/docs/pycon2010/sargon.jpg and /dev/null differ diff --git a/docs/pycon2010/schematic.png b/docs/pycon2010/schematic.png deleted file mode 100644 index d4b39092..00000000 Binary files a/docs/pycon2010/schematic.png and /dev/null differ diff --git a/docs/pycon2010/script.txt b/docs/pycon2010/script.txt deleted file mode 100644 index c638b1a7..00000000 --- a/docs/pycon2010/script.txt +++ /dev/null @@ -1,5 +0,0 @@ -loot -loot -drink /* arrr */ 2 # matey -drink chardonnay - diff --git a/docs/pycon2010/strategy.png b/docs/pycon2010/strategy.png deleted file mode 100644 index 7d6afdcd..00000000 Binary files a/docs/pycon2010/strategy.png and /dev/null differ diff --git a/docs/pycon2010/transcript.txt b/docs/pycon2010/transcript.txt deleted file mode 100644 index d00e44fc..00000000 --- a/docs/pycon2010/transcript.txt +++ /dev/null @@ -1,12 +0,0 @@ -arrr> loot -Now we gots 4 doubloons -arrr> loot -Now we gots 5 doubloons -arrr> drink 3 -Now we gots 2 doubloons -arrr> drink chardonnay -What's "chardonnay"? I'll take rrrum. -Now we gots 1 doubloons -arrr> quit -Quiterrr! - diff --git a/docs/pycon2010/urwid.png b/docs/pycon2010/urwid.png deleted file mode 100644 index c2b5a9bf..00000000 Binary files a/docs/pycon2010/urwid.png and /dev/null differ diff --git a/docs/pycon2010/web-2-0-logos.gif b/docs/pycon2010/web-2-0-logos.gif deleted file mode 100644 index 9d48e37d..00000000 Binary files a/docs/pycon2010/web-2-0-logos.gif and /dev/null differ -- cgit v1.2.1 From d9f441befaabb96887b8ffd810b97e32d25dc27d Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 8 Nov 2017 14:23:27 -0500 Subject: Fixed incorrect http link in the README --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/index.rst b/docs/index.rst index d84558af..d89f1d7e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -46,7 +46,7 @@ Resources * cmd_ * `cmd2 project page`_ * `project bug tracker`_ -* Florida PyCon 2017: `slides `_ +* Florida PyCon 2017: `slides `_ * PyOhio 2011: `video `_ * PyCon 2010: `presentation `_, `video `_ -- cgit v1.2.1 From 53aaee95bb3f9524d13853a7ac5575aedba260d4 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 8 Nov 2017 14:27:28 -0500 Subject: Removed broken link from docs --- docs/index.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/index.rst b/docs/index.rst index d89f1d7e..dd410a44 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -48,8 +48,7 @@ Resources * `project bug tracker`_ * Florida PyCon 2017: `slides `_ * PyOhio 2011: `video `_ -* PyCon 2010: `presentation `_, - `video `_ +* PyCon 2010: `video `_ These docs will refer to ``App`` as your ``cmd2.Cmd`` subclass, and ``app`` as an instance of ``App``. Of -- cgit v1.2.1 From 5fa0916115faf55fb513161b4de0d9d8544bcbc2 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 9 Nov 2017 02:32:36 -0500 Subject: Updated docs to make it more clear that you need to update shortcuts attribute before calling super class __init__ --- docs/index.rst | 1 - docs/settingchanges.rst | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/index.rst b/docs/index.rst index dd410a44..3a52b9b5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -48,7 +48,6 @@ Resources * `project bug tracker`_ * Florida PyCon 2017: `slides `_ * PyOhio 2011: `video `_ -* PyCon 2010: `video `_ These docs will refer to ``App`` as your ``cmd2.Cmd`` subclass, and ``app`` as an instance of ``App``. Of diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst index 326db3f5..0a24651b 100644 --- a/docs/settingchanges.rst +++ b/docs/settingchanges.rst @@ -19,11 +19,11 @@ Whether or not you set ``case_insensitive``, *please do not* define command method names with any uppercase letters. ``cmd2`` expects all command methods to be lowercase. -Shortcuts -========= +Shortcuts (command aliases) +=========================== -Special-character shortcuts for common commands can make life more convenient for your -users. Shortcuts are used without a space separating them from their arguments, +Command aliases for long command names such as special-character shortcuts for common commands can make life more +convenient for your users. Shortcuts are used without a space separating them from their arguments, like ``!ls``. By default, the following shortcuts are defined: ``?`` @@ -42,7 +42,20 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the {'shortcut': 'command_name'} (omit ``do_``):: class App(Cmd2): - Cmd2.shortcuts.update({'*': 'sneeze', '~': 'squirm'}) + def __init__(self): + # Make sure you update the shortcuts attribute before calling the super class __init__ + self.shortcuts.update({'*': 'sneeze', '~': 'squirm'}) + + # Make sure to call this super class __init__ after updating shortcuts + cmd2.Cmd.__init__(self) + +.. warning:: + + Command aliases needed to be created by updating the ``shortcuts`` dictionary attribute prior to calling the + ``cmd2.Cmd`` super class ``__init__()`` method. Moreover, that super class init method needs to be called after + updating the ``shortcuts`` attribute This warning applies in general to many other attributes which are not + settable at runtime such as ``commentGrammars``, ``multilineCommands``, etc. + Default to shell ================ -- cgit v1.2.1 From da099c2dff669d722b2c81a2224de6c0d2695449 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 15 Nov 2017 21:26:08 -0500 Subject: Added a note to the installation instructions section of user manual --- docs/install.rst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/install.rst b/docs/install.rst index 1edba409..9e330c3c 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -107,6 +107,10 @@ the following Python packages are installed: * pyparsing * pyperclip +On Windows, there is an additional dependency: + + * pyreadline + Upgrading cmd2 -------------- -- cgit v1.2.1