Mercurial > python-cmd2
diff docs/freefeatures.rst @ 331:6306edc46a6e
more docs
author | cat@eee |
---|---|
date | Fri, 12 Feb 2010 21:41:17 -0500 |
parents | c69ad8418d39 |
children | 49bea7cab179 |
line wrap: on
line diff
--- a/docs/freefeatures.rst Fri Feb 12 16:28:15 2010 -0500 +++ b/docs/freefeatures.rst Fri Feb 12 21:41:17 2010 -0500 @@ -5,15 +5,31 @@ These features are provided "for free" to a cmd_-based application simply by replacing ``import cmd`` with ``import cmd2 as cmd``. +Abbreviated commands +==================== + +``cmd2`` apps will accept shortened command names +so long as there is no ambiguity. Thus, if +``do_divide`` is defined, then ``divid``, ``div``, +or even ``d`` will suffice, so long as there are +no other commands defined beginning with *divid*, +*div*, or *d*. + +This behavior can be turned off with ``app.abbrev`` (see :ref:`parameters`) + Script files ============ -Commands can be loaded and run from text files. +Text files can serve as scripts for your ``cmd2``-based +application, with the ``load``, ``save``, and ``edit`` +commands. .. automethod:: cmd2.Cmd.do_load .. automethod:: cmd2.Cmd.do_save +.. automethod:: cmd2.Cmd.do_edit + Output redirection ================== @@ -29,7 +45,6 @@ .. _pywin32:: http://sourceforge.net/projects/pywin32/ .. _xclip:: http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/ - Commands at invocation ====================== @@ -113,5 +128,29 @@ synonyms ``exit`` and simply ``q``). It's trivial, but it's one less thing for you to remember. +Comments +======== + +Comments are omitted from the argument list +before it is passed to a ``do_`` method. By +default, both Python-style and C-style comments +are recognized; you may change this by overriding +``app.commentGrammars`` with a different pyparsing_ +grammar. + +Comments can be useful in :ref:`script`s. Used +in an interactive session, they may indicate +mental imbalance. + +:: + + def do_speak(self, arg): + self.stdout.write(arg + '\n') + +:: + + (Cmd) speak it was /* not */ delicious! # Yuck! + it was delicious! + Transcript-based testing ========================