Lines Matching full:line
1 """A generic class to build line-oriented command interpreters.
6 2. A command is parsed out of each line by collecting the prefix composed
9 is passed a single argument consisting of the remainder of the line.
10 4. Typing an empty line repeats the last command. (Actually, it calls the
20 arguments text, line, begidx, endidx. text is string we are matching
21 against, all returned matches must begin with it. line is the current
22 input line (lstripped), begidx and endidx are the beginning and end
33 in the help messages. If empty, no ruler line is drawn. It defaults to "=".
56 """A simple framework for writing line-oriented command interpreters.
61 A Cmd instance or subclass instance is a line-oriented interpreter
80 """Instantiate a line-oriented interpreter framework.
105 the remainder of the line as argument.
126 line = self.cmdqueue.pop(0)
130 line = raw_input(self.prompt)
132 line = 'EOF'
136 line = self.stdin.readline()
137 if not len(line):
138 line = 'EOF'
140 line = line.rstrip('\r\n')
141 line = self.precmd(line)
142 stop = self.onecmd(line)
143 stop = self.postcmd(stop, line)
154 def precmd(self, line):
155 """Hook method executed just before the command line is
159 return line
161 def postcmd(self, stop, line):
176 def parseline(self, line):
177 """Parse the line into a command name and a string containing
178 the arguments. Returns a tuple containing (command, args, line).
179 'command' and 'args' may be None if the line couldn't be parsed.
181 line = line.strip()
182 if not line:
183 return None, None, line
184 elif line[0] == '?':
185 line = 'help ' + line[1:]
186 elif line[0] == '!':
188 line = 'shell ' + line[1:]
190 return None, None, line
191 i, n = 0, len(line)
192 while i < n and line[i] in self.identchars: i = i+1
193 cmd, arg = line[:i], line[i:].strip()
194 return cmd, arg, line
196 def onecmd(self, line):
206 cmd, arg, line = self.parseline(line)
207 if not line:
210 return self.default(line)
211 self.lastcmd = line
212 if line == 'EOF' :
215 return self.default(line)
220 return self.default(line)
224 """Called when an empty line is entered in response to the prompt.
233 def default(self, line):
234 """Called on an input line when the command prefix is not recognized.
240 self.stdout.write('*** Unknown syntax: %s\n'%line)
243 """Method called to complete an input line when no command-specific
264 line = origline.lstrip()
265 stripped = len(origline) - len(line)
269 cmd, args, foo = self.parseline(line)
279 self.completion_matches = compfunc(text, line, begidx, endidx)