Commit 554b6d89 authored by Seblu's avatar Seblu
Browse files

Recursive alias subsitution

We now can use alias of alias (limited to 10 iterations).
parent e5c0b8c5
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -119,12 +119,16 @@ class Aliases(dict):
            fparser.write(open(filename, "w"))

    def substitute(self, argv):
        # trip is the number of subtitution of an alias
        # maximum number of trip is set to 10
        for trip in range(10):
            if argv[0] in self:
                oldargv = argv[1:]
                argv = shlex.split(self[argv[0]])
                argv.extend(oldargv)
        return argv


class Command(object):
    '''Base of all command class'''

@@ -187,6 +191,7 @@ class OptionCommand(Command):
        '''Proxy to OptionParser'''
        self.optionparser.set_usage(*args, **kwargs)


class RemoteCommand(OptionCommand):
    '''Command which needs connection to server'''

@@ -229,6 +234,7 @@ class RemoteCommand(OptionCommand):
            pls.append("%s%s:%s%s"%(self.tdtc(tn), tn, self.tdc(tn), self.tdr(tn, tl[tn])))
        self.printer.out("%s%s"%(" ".join(pls), color["reset"]))


class TqlCommand(RemoteCommand):
    '''Command which handle TQL stuff'''