From 37c68b7ba6421d575a9b00b12766d47aff4d89ce Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 20 Jul 2012 19:24:30 +0200 Subject: [PATCH] Search and execute short command alias --- weboob/tools/application/repl.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/weboob/tools/application/repl.py b/weboob/tools/application/repl.py index b382f0e3..d38fc349 100644 --- a/weboob/tools/application/repl.py +++ b/weboob/tools/application/repl.py @@ -322,6 +322,23 @@ class ReplApplication(Cmd, ConsoleApplication): stop = None return stop + def parseline(self, line): + """ + This REPL method is overrided to search "short" alias of commands + """ + cmd, arg, ignored = Cmd.parseline(self, line) + + names = set(name for name in self.get_names() if name.startswith('do_')) + + if 'do_' + cmd not in names: + long = set(name for name in names if name.startswith('do_' + cmd)) + # if more than one result, ambiguous command, do nothing (error will display suggestions) + if len(long) == 1: + cmd = long.pop()[3:] + + return cmd, arg, ignored + + def onecmd(self, line): """ This REPL method is overrided to catch some particular exceptions.