cmd.rst 7.71 KB

:mod:`cmd` --- Support for line-oriented command interpreters

The :class:`Cmd` class provides a simple framework for writing line-oriented command interpreters. These are often useful for test harnesses, administrative tools, and prototypes that will later be wrapped in a more sophisticated interface.

A :class:`Cmd` instance or subclass instance is a line-oriented interpreter framework. There is no good reason to instantiate :class:`Cmd` itself; rather, it's useful as a superclass of an interpreter class you define yourself in order to inherit :class:`Cmd`'s methods and encapsulate action methods.

The optional argument completekey is the :mod:`readline` name of a completion key; it defaults to Tab. If completekey is not :const:`None` and :mod:`readline` is available, command completion is done automatically.

The optional arguments stdin and stdout specify the input and output file objects that the Cmd instance or subclass instance will use for input and output. If not specified, they will default to sys.stdin and sys.stdout.

Cmd Objects

A :class:`Cmd` instance has the following methods:

Instances of :class:`Cmd` subclasses have some public instance variables: