| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-shlex.html" /> |
| 13 | <link rel="prev" href="module-calendar.html" /> |
| 14 | <link rel="parent" href="misc.html" /> |
| 15 | <link rel="next" href="Cmd-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>5.20 cmd -- Support for line-oriented command interpreters</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="5.19 calendar " |
| 25 | href="module-calendar.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services" |
| 28 | href="misc.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="5.20.1 Cmd Objects" |
| 31 | href="Cmd-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-calendar.html">5.19 calendar </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="Cmd-objects.html">5.20.1 Cmd Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION0072000000000000000000"> |
| 56 | 5.20 <tt class="module">cmd</tt> -- |
| 57 | Support for line-oriented command interpreters</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-cmd"></A> |
| 62 | |
| 63 | <P> |
| 64 | The <tt class="class">Cmd</tt> class provides a simple framework for writing |
| 65 | line-oriented command interpreters. These are often useful for |
| 66 | test harnesses, administrative tools, and prototypes that will |
| 67 | later be wrapped in a more sophisticated interface. |
| 68 | |
| 69 | <P> |
| 70 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 71 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-1460' xml:id='l2h-1460' class="class">Cmd</tt></b>(</nobr></td> |
| 72 | <td><var></var><big>[</big><var>completekey</var><big>[</big><var>, |
| 73 | stdin</var><big>[</big><var>, stdout</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 74 | <dd> |
| 75 | A <tt class="class">Cmd</tt> instance or subclass instance is a line-oriented |
| 76 | interpreter framework. There is no good reason to instantiate |
| 77 | <tt class="class">Cmd</tt> itself; rather, it's useful as a superclass of an |
| 78 | interpreter class you define yourself in order to inherit |
| 79 | <tt class="class">Cmd</tt>'s methods and encapsulate action methods. |
| 80 | |
| 81 | <P> |
| 82 | The optional argument <var>completekey</var> is the <tt class="module"><a href="module-readline.html">readline</a></tt> name |
| 83 | of a completion key; it defaults to <kbd>Tab</kbd>. If <var>completekey</var> is |
| 84 | not <tt class="constant">None</tt> and <tt class="module"><a href="module-readline.html">readline</a></tt> is available, command completion |
| 85 | is done automatically. |
| 86 | |
| 87 | <P> |
| 88 | The optional arguments <var>stdin</var> and <var>stdout</var> specify the |
| 89 | input and output file objects that the Cmd instance or subclass |
| 90 | instance will use for input and output. If not specified, they |
| 91 | will default to <var>sys.stdin</var> and <var>sys.stdout</var>. |
| 92 | |
| 93 | <P> |
| 94 | |
| 95 | <span class="versionnote">Changed in version 2.3: |
| 96 | The <var>stdin</var> and <var>stdout</var> parameters were added..</span> |
| 97 | |
| 98 | </dl> |
| 99 | |
| 100 | <P> |
| 101 | |
| 102 | <p><br /></p><hr class='online-navigation' /> |
| 103 | <div class='online-navigation'> |
| 104 | <!--Table of Child-Links--> |
| 105 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 106 | |
| 107 | <UL CLASS="ChildLinks"> |
| 108 | <LI><A href="Cmd-objects.html">5.20.1 Cmd Objects</a> |
| 109 | </ul> |
| 110 | <!--End of Table of Child-Links--> |
| 111 | </div> |
| 112 | |
| 113 | <DIV CLASS="navigation"> |
| 114 | <div class='online-navigation'> |
| 115 | <p></p><hr /> |
| 116 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 117 | <tr> |
| 118 | <td class='online-navigation'><a rel="prev" title="5.19 calendar " |
| 119 | href="module-calendar.html"><img src='../icons/previous.png' |
| 120 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 121 | <td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services" |
| 122 | href="misc.html"><img src='../icons/up.png' |
| 123 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 124 | <td class='online-navigation'><a rel="next" title="5.20.1 Cmd Objects" |
| 125 | href="Cmd-objects.html"><img src='../icons/next.png' |
| 126 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 127 | <td align="center" width="100%">Python Library Reference</td> |
| 128 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 129 | href="contents.html"><img src='../icons/contents.png' |
| 130 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 131 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 132 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 133 | <td class='online-navigation'><a rel="index" title="Index" |
| 134 | href="genindex.html"><img src='../icons/index.png' |
| 135 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 136 | </tr></table> |
| 137 | <div class='online-navigation'> |
| 138 | <b class="navlabel">Previous:</b> |
| 139 | <a class="sectref" rel="prev" href="module-calendar.html">5.19 calendar </A> |
| 140 | <b class="navlabel">Up:</b> |
| 141 | <a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A> |
| 142 | <b class="navlabel">Next:</b> |
| 143 | <a class="sectref" rel="next" href="Cmd-objects.html">5.20.1 Cmd Objects</A> |
| 144 | </div> |
| 145 | </div> |
| 146 | <hr /> |
| 147 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 148 | </DIV> |
| 149 | <!--End of Navigation Panel--> |
| 150 | <ADDRESS> |
| 151 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 152 | </ADDRESS> |
| 153 | </BODY> |
| 154 | </HTML> |