Used as the command which will be executed by the onecmd() method the This method is a stub inĬmd it exists to be overridden by subclasses. Hook method executed just before the command line line is interpreted, butĪfter the input prompt is generated and issued. Method called to display a list of strings as a compact set of columns.Įach column is only as wide as necessary.Ĭolumns are separated by two spaces for readability. Method called to complete an input line when no command-specificĬomplete_*() method is available. completedefault ( text, line, begidx, endidx ) ¶ This method is not overridden, it prints an error message and returns. Method called on an input line when the command prefix is not recognized. Method is not overridden, it repeats the last nonempty command entered. Method called when an empty line is entered in response to the prompt. Str, the return value of that method is returned, otherwise the return valueįrom the default() method is returned. If there is a do_*() method for the command Return value is a flag indicating whether interpretation of commands by the Precmd() and postcmd() methods for useful execution hooks. This may be overridden, but should not normally need to be see the Interpret the argument as though it had been typed in response to the prompt. Help_*() methods or commands that have docstrings), and also lists any With no argument, do_help() lists allĪvailable help topics (that is, all commands with corresponding Help_bar(), and if that is not present, prints the docstring ofĭo_bar(), if available. Method, called with an argument 'bar', invokes the corresponding method Provide different completion depending upon which position the argument is in.Īll subclasses of Cmd inherit a predefined do_help(). The current input line with leading whitespace removed, begidx and endidxĪre the beginning and ending indexes of the prefix text, which could be used to We are attempting to match: all returned matches must begin with it. If completion is enabled, completing commands will be done automatically, andĬompleting of commands args is done by calling complete_foo() withĪrguments text, line, begidx, and endidx. The stop argument to postcmd() is the return value from the command’s This method will return when the postcmd() method returns a true value. Method do_shell() (if such a method is defined). Special case, a line beginning with the character '!' is dispatched to the As a special case, a line beginning with theĬharacter '?' is dispatched to the method do_help(). Moves the cursor to the right non-destructively, Control- B moves theĬursor to the left non-destructively, etc.).Īn end-of-file on input is passed back as the string 'EOF'.Īn interpreter instance will recognize a command name foo if and only if it To the last command, Control- N forward to the next one, Control- F If the readline module is loaded, input will automatically inheritīash-like history-list editing (e.g. Prompt (this overrides the intro class attribute). The optional argument is a banner or intro string to be issued before the first Received input, and dispatch to action methods, passing them the remainder of Repeatedly issue a prompt, accept input, parse an initial prefix off the Use_rawinput attribute to False, otherwise stdin will beĪ Cmd instance has the following methods: Cmd. If you want a given stdin to be used, make sure to set the instance’s If not specified, they will default to sys.stdin and Objects that the Cmd instance or subclass instance will use for input and The optional arguments stdin and stdout specify the input and output file Readline is available, command completion is done automatically. The optional argument completekey is the readline name of a completion To inherit Cmd’s methods and encapsulate action methods. It’s useful as a superclass of an interpreter class you define yourself in order There is no good reason to instantiate Cmd itself rather, Cmd ( completekey = 'tab', stdin = None, stdout = None ) ¶Ī Cmd instance or subclass instance is a line-oriented interpreterįramework. Tools, and prototypes that will later be wrapped in a more sophisticated These are often useful for test harnesses, administrative The Cmd class provides a simple framework for writing line-orientedĬommand interpreters. Cmd - Support for line-oriented command interpreters ¶
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |