def default(self, line): """Called when an unknown command is entered.""" if line == 'EOF': return self.onecmd('quit') else: pieces = line.split(' ', 1) command = pieces[0] rest = pieces[1:] or [''] matches = [d.replace('do_', '') for d in dir(self) if d.startswith('do_') and \ d.replace('do_', '').startswith(command)] if len(matches) == 1: newcommand = '%s %s' % (matches[0], rest[0]) print "expanded>", newcommand self.onecmd(newcommand) elif matches: def highlight(text): l = len(command) text = text[:l] + ansi.RESET + text[l:] text = ansi.RED + ansi.BOLD + text return text print "Possible matches:" print '\t' + '\n\t'.join(highlight(match) for match in matches) print "Type a longer prefix to clarify." else: Cmd.default(self, line)
def default(self,line): keys = self.re_keys.findall(line.strip()) if ''.join(keys) == line.strip(): for key in keys: parts = re.split(r'(\D+)',key) count = int(parts[0]) if len(parts[0]) > 0 else 1 key = parts[1] for x in xrange(0,min(count,_max_key_quantifier)): self.quick_keys[key]('') time.sleep(_quick_key_interval) else: Cmd.default(self,line)
def default(self, line): line = line.lstrip() if line.startswith('>'): # evaluate python code return self.do_eval(line[1:]) if line.startswith('!'): # run a local command return self.do_shell(line[1:]) if line == '..': return True Cmd.default(self, line)
def default(self, line): '''Handle aliases.''' parts = line.split(None, 1) if len(parts) > 0 and parts[0] in self.aliases: newline = self.aliases[parts[0]] if len(parts) > 1: newline += ' ' + parts[1] return self.onecmd(newline) return _Cmd.default(self, line)
def default(self, line): if line.startswith("_debug"): print(line) print("file:{},suffix:{},basename:{}".format( self._env.file, self._env.suffix, self._env.basename)) # print("tmpdir:{}".format(self._exec.tmpdir)) print(self._env.list) return False else: return Cmd.default(self, line)
def default(self, line): # pylint: disable=exec-used """ This function handles the command line if no command was found. :param line: command line :return: None """ if not self.allow_exec: return Cmd.default(self, line) try: exec(line) in self._locals, self._globals except Exception as e: self.stdout.write('%s : %s\n' % (e.__class__.__name__, e))
def default(self, line): Cmd.default(self, line) self._last_command_failed = True
def default(self, line): Cmd.default(self, line) raise UnknownCallException
def default(self, line): if line.lstrip().startswith('--'): return # ignore comments Cmd.default(self, line)
def default(self, line): ''' The default line handler ''' try: self.controller.set_parameters(line, short_syntax=True) except Exception: return Cmd.default(self, line)
def default(self, line): Cmd.default(self, line)
def default(self, line: str): subcommand = cli.commands.get(line) if subcommand: self.ctx.invoke(subcommand) else: return Cmd.default(self, line)