Command-Line Modules

cmd

Framework for interactive command interpreters with do_NAME methods, help and command completion hooks. onecmd dispatches a single line without entering an input loop. Commands are application-defined; do not pass arbitrary command text to a shell.

Formal Syntax & Structure

python syntaxpython
import cmd

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from cmd import Cmdclass Console(Cmd):    def do_echo(self, arg):        print(arg)
Console().onecmd("echo tea")
Python Reference