Lines Matching +refs:is +refs:completion +refs:line
1 :mod:`cmd` --- Support for line-oriented command interpreters
5 :synopsis: Build line-oriented command interpreters.
13 The :class:`Cmd` class provides a simple framework for writing line-oriented
20 A :class:`Cmd` instance or subclass instance is a line-oriented interpreter
21 framework. There is no good reason to instantiate :class:`Cmd` itself; rather,
25 The optional argument *completekey* is the :mod:`readline` name of a completion
26 key; it defaults to :kbd:`Tab`. If *completekey* is not :const:`None` and
27 :mod:`readline` is available, command completion is done automatically.
51 the line as argument.
53 The optional argument is a banner or intro string to be issued before the first
56 If the :mod:`readline` module is loaded, input will automatically inherit
62 An end-of-file on input is passed back as the string ``'EOF'``.
69 has a method :meth:`do_foo`. As a special case, a line beginning with the
70 character ``'?'`` is dispatched to the method :meth:`do_help`. As another
71 special case, a line beginning with the character ``'!'`` is dispatched to the
72 method :meth:`do_shell` (if such a method is defined).
75 The *stop* argument to :meth:`postcmd` is the return value from the command's
78 If completion is enabled, completing commands will be done automatically, and
79 completing of commands args is done by calling :meth:`complete_foo` with
80 arguments *text*, *line*, *begidx*, and *endidx*. *text* is the string prefix
81 we are attempting to match: all returned matches must begin with it. *line* is
82 the current input line with leading whitespace removed, *begidx* and *endidx*
84 provide different completion depending upon which position the argument is in.
88 :meth:`help_bar`, and if that is not present, prints the docstring of
90 available help topics (that is, all commands with corresponding
100 return value is a flag indicating whether interpretation of commands by the
101 interpreter should stop. If there is a :meth:`do_\*` method for the command
102 *str*, the return value of that method is returned, otherwise the return value
103 from the :meth:`default` method is returned.
108 Method called when an empty line is entered in response to the prompt. If this
109 method is not overridden, it repeats the last nonempty command entered.
112 .. method:: Cmd.default(line)
114 Method called on an input line when the command prefix is not recognized. If
115 this method is not overridden, it prints an error message and returns.
118 .. method:: Cmd.completedefault(text, line, begidx, endidx)
120 Method called to complete an input line when no command-specific
121 :meth:`complete_\*` method is available. By default, it returns an empty list.
124 .. method:: Cmd.precmd(line)
126 Hook method executed just before the command line *line* is interpreted, but
127 after the input prompt is generated and issued. This method is a stub in
128 :class:`Cmd`; it exists to be overridden by subclasses. The return value is
130 :meth:`precmd` implementation may re-write the command or simply return *line*
134 .. method:: Cmd.postcmd(stop, line)
136 Hook method executed just after a command dispatch is finished. This method is
137 a stub in :class:`Cmd`; it exists to be overridden by subclasses. *line* is the
138 command line which was executed, and *stop* is a flag which indicates whether
147 Hook method executed once when :meth:`cmdloop` is called. This method is a stub
153 Hook method executed once when :meth:`cmdloop` is about to return. This method
154 is a stub in :class:`Cmd`; it exists to be overridden by subclasses.
176 A list of queued input lines. The cmdqueue list is checked in
177 :meth:`cmdloop` when new input is needed; if it is nonempty, its elements
195 topics (that is, there are :meth:`help_\*` methods without corresponding
202 (that is, there are :meth:`do_\*` methods without corresponding :meth:`help_\*`
209 empty, no ruler line is drawn. It defaults to ``'='``.
218 support :program:`Emacs`\ -like line editing and command-history keystrokes.)
228 The :mod:`cmd` module is mainly useful for building custom shells that let a
235 :class:`Cmd` subclass with method named :meth:`do_forward`. The argument is
236 converted to a number and dispatched to the turtle module. The docstring is
240 the :meth:`~Cmd.precmd` method which is responsible for converting the input to
274 print('Current position is %d %d\n' % position())
277 print('Current heading is %d\n' % (heading(),))
302 def precmd(self, line):
303 line = line.lower()
304 if self.file and 'playback' not in line:
305 print(line, file=self.file)
306 return line
320 Here is a sample session with the turtle shell showing the help functions, using
338 Current position is 0 0
341 Current heading is 0
358 Current heading is 180
374 Current position is 0 0
376 Current heading is 0
378 Current heading is 180