From ec7084389fec2f1bf355aff88c6b41e8c6fa6275 Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Fri, 20 May 2011 17:19:21 +0200 Subject: [PATCH] Alias substitution is now handled in alias manager --- cccli/cli.py | 6 ++---- cccli/commands.py | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cccli/cli.py b/cccli/cli.py index 9dbf8ff..b9cb2e3 100644 --- a/cccli/cli.py +++ b/cccli/cli.py @@ -112,10 +112,8 @@ class Cli(object): if len(argv) == 0: continue # alias subsitution - if argv[0] in self.aliases: - oldargv = argv[1:] - argv = shlex.split(self.aliases[argv[0]]) - argv.extend(oldargv) + argv = self.aliases.substitute(argv) + # command execution self._exec_command(argv) except KeyboardInterrupt: self.printer.out("") diff --git a/cccli/commands.py b/cccli/commands.py index c912175..f424cbb 100644 --- a/cccli/commands.py +++ b/cccli/commands.py @@ -7,6 +7,7 @@ CloudControl CLI commands module import re import ConfigParser import os +import shlex from cccli.exception import * from cccli.command import * @@ -98,3 +99,10 @@ class Aliases(dict): for n,v in self.items(): fparser.set("alias", n, v) fparser.write(open(filename, "w")) + + def substitute(self, argv): + if argv[0] in self: + oldargv = argv[1:] + argv = shlex.split(self[argv[0]]) + argv.extend(oldargv) + return argv -- GitLab