From 363c4626714f7e6772b5aa5a53866b1a5c941215 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Mon, 14 Feb 2011 15:34:20 +0100
Subject: [PATCH] VmCommand now use TqlCommand

---
 cccli/command/vm.py | 17 +++++++++--------
 cccli/printer.py    |  2 +-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cccli/command/vm.py b/cccli/command/vm.py
index 8aa7f09..b53de5c 100644
--- a/cccli/command/vm.py
+++ b/cccli/command/vm.py
@@ -6,13 +6,13 @@ CloudControl VM related commands
 from cccli.exception import *
 from sjrpc.core.exceptions import *
 from cccli.printer import Printer, color
-from cccli.command.command import OptionCommand
+from cccli.command.command import TqlCommand
 
-class VmCommand(OptionCommand):
+class VmCommand(TqlCommand):
     '''Command for vm style'''
 
     def __init__(self, cli, argv0):
-        OptionCommand.__init__(self, cli, argv0)
+        TqlCommand.__init__(self, cli, argv0)
         self.set_usage("%prog [options] <tql>")
         self.add_option("--raw", action="store_true", dest="raw",
                         help="Don't append filter on request")
@@ -22,16 +22,17 @@ class VmCommand(OptionCommand):
                         help="Don't ask confirmation (Dangerous)")
 
     def _vm_action(self, argv, filters=None):
-        self.parse_args()
-        if len(args) == 0:
+        # parse args
+        self.parse_args(argv)
+        if len(self.args) == 0:
             raise cmdBadArgument()
-        tql = str.join("", args)
+        tql = str.join("", self.args)
         # append securty options by command name
         if filters is not None and not self.options.raw:
             tql += filters
         if self.options.direct:
             try:
-                objs = self.cli.rpc.call(argv[0], tql)
+                objs = self.cli.rpc.call(self.args[0], tql)
             except RpcError as e:
                 raise cmdError("RPCError: %s"%str(e))
         else:
@@ -43,7 +44,7 @@ class VmCommand(OptionCommand):
             # no result, goodbye
             if len(objs) == 0:
                 raise cmdWarning("tql: '%s': No result."%tql)
-            self.printer.out("You will %s:"%argv[0])
+            self.printer.out("You will %s:"%self.args[0])
             for obj in objs:
                 self.printer.out("%sid:%s%s%s"%(color["green"],color["yellow"],obj["id"],color["reset"]))
             self.printer.out("%sCount: %s%s"%(color["green"],color["reset"], len(objs)))
diff --git a/cccli/printer.py b/cccli/printer.py
index bc0a4aa..ef36e68 100644
--- a/cccli/printer.py
+++ b/cccli/printer.py
@@ -147,7 +147,7 @@ class Printer(object):
         h = list(self.history)
         self.history.clear()
         try:
-            r = self.getline(prompt, history=False)
+            r = self.getline(prompt)
         finally:
             self.history.load(h)
         return r
-- 
GitLab