changeset 336:8aa71e8f1064

alternatives
author catherine@Drou
date Mon, 15 Feb 2010 22:07:37 -0500
parents f69211e2c570
children 2ce34ad4e520
files cmd2.py docs/alternatives.rst docs/unfreefeatures.rst
diffstat 3 files changed, 60 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Mon Feb 15 17:45:52 2010 -0500
+++ b/cmd2.py	Mon Feb 15 22:07:37 2010 -0500
@@ -455,8 +455,11 @@
                   'underline':{True:'\x1b[4m',False:'\x1b[24m'}}
     colors = (platform.system() != 'Windows')
     def colorize(self, val, color):
-        '''Wraps `val` in `color` markers (one of: red/blue/green/cyan/magenta, bold, underline),
-           but only if `colors` environment variable is True'''
+        '''Given a string (``val``), returns that string wrapped in UNIX-style 
+           special characters that turn on (and then off) text color and style.
+           If the ``colors`` environment paramter is ``False``, or the application
+           is running on Windows, will return ``val`` unchanged.
+           Available colors/styles: red/blue/green/cyan/magenta, bold, underline'''
         if self.colors and (self.stdout == self.initial_stdout):
             return self.colorcodes[color][True] + val + self.colorcodes[color][False]
         return val
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/alternatives.rst	Mon Feb 15 22:07:37 2010 -0500
@@ -0,0 +1,50 @@
+============================
+Alternatives to cmd and cmd2
+============================
+
+For programs that do not interact with the user in a continuous loop - 
+programs that simply accept a set of arguments from the command line, return 
+results, and do not keep the user within the program's environment - all
+you need are sys_\ .argv (the command-line arguments) and optparse_
+(for parsing UNIX-style options and flags).
+
+.. _optparse: http://docs.python.org/library/optparse.html#module-optparse
+
+.. _sys: http://docs.python.org/library/sys.html#module-sys
+
+.. _curses: http://docs.python.org/library/curses.html#module-curses
+
+.. _cmd: http://docs.python.org/library/cmd.html#module-cmd
+
+The curses_ module produces applications that interact via a plaintext
+terminal window, but are not limited to simple text input and output;
+they can paint the screen with options that are selected from using the
+cursor keys.  However, programming a curses_-based application is not as
+straightforward as using cmd_.
+
+Several packages in PyPI enable interactive command-line applications
+approximately similar in concept to cmd_ applications.  None of them 
+share cmd2's close ties to cmd, but they may be worth investigating
+nonetheless.
+
+  * CmdLoop_
+  * cly_
+  * CmDO_ (As of Feb. 2010, webpage is missing.)
+  * pycopia-CLI_
+  
+cmdln_, another package in PyPI, is an extension to cmd_ and, though it
+doesn't retain full cmd_ compatibility, shares its basic structure with
+cmd_.
+
+.. _cmdln_ http://pypi.python.org/pypi/cmdln
+
+.. _CmdLoop: http://pypi.python.org/pypi/CmdLoop
+
+.. _cly: http://pypi.python.org/pypi/cly
+
+.. _CmDO: http://pypi.python.org/pypi/CmDO/0.7
+
+.. _pycopia-CLI: http://pypi.python.org/pypi/pycopia-CLI/1.0
+
+I've found several alternatives to cmd in the Cheese Shop - CmdLoop, cly, CMdO, and pycopia. cly looks wonderful, but I haven't been able to get it working under Windows, and that's a show-stopper for many potential sqlpython users. In any case, none of the alternatives are based on cmd - they're written from scratch, which means that a cmd-based app would need complete rewriting to use them. I like sticking close to the Standard Library whenever possible. cmd2 lets you do that.
+
--- a/docs/unfreefeatures.rst	Mon Feb 15 17:45:52 2010 -0500
+++ b/docs/unfreefeatures.rst	Mon Feb 15 22:07:37 2010 -0500
@@ -181,6 +181,11 @@
   
 .. _quiet:
 
+color
+=====
+
+.. automethod:: cmd2.Cmd.do_quit
+
 Quiet
 =====
 
@@ -211,6 +216,3 @@
 	   2. salty
 	Sauce? 2
 	wheaties with salty sauce, yum!
-
-``color``
-=========