From 6d53c823ecddf21f62ef25ef9289e4e8f50eb8a8 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Mon, 14 Feb 2011 20:38:02 +0100
Subject: [PATCH] commands tags use TqlCommand

---
 cccli/command/tag.py | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/cccli/command/tag.py b/cccli/command/tag.py
index e38ef9b..cda438c 100644
--- a/cccli/command/tag.py
+++ b/cccli/command/tag.py
@@ -8,31 +8,22 @@ CloudControl tag releated commands
 from cccli.exception import *
 from sjrpc.core.exceptions import *
 from cccli.printer import Printer, color
-from cccli.command.command import OptionCommand, TqlCommand
+from cccli.command.command import TqlCommand
 
 from optparse import OptionParser
 
-class Command_tags(OptionCommand):
-    '''List static tags on an account'''
+class Command_tags(TqlCommand):
+    '''List only static tags'''
 
     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")
-        self.add_option("-n", "--no-tagdisplay", action="store_false", dest="tagdisplay", default=True,
-                        help="No tag display system")
 
     def __call__(self, argv):
         # Parse argline
         self.parse_args(argv)
-        # handle tagdisplay
-        if self.options.tagdisplay:
-            self.td = self.cli.tagdisplay.resolve
-            self.tc = self.cli.tagdisplay.color
-        else:
-            self.td = lambda tagname, tagvalue: unicode(tagvalue)
-            self.tc = lambda tagname: color["reset"]
         # append current login if nothing asked
         if len(self.args) == 0:
             tql = "a=%s"%self.cli.settings["login"]
@@ -43,18 +34,18 @@ class Command_tags(OptionCommand):
             tql += "&a"
         # ask server
         try:
-            objs = self.cli.rpc.call("tags", tql)
+            objs = self.rpccall("tags", tql, _status=False)
         except RpcError as e:
             raise cmdError("RPCError: %s"%str(e))
         # display answer
         for o in objs:
-            id = self.td("id", o.pop("id"))
-            tags = " ".join([ "%s%s:%s%s"%(color["reset"],
+            tid = self.tdr("id", o.pop("id"))
+            tags = " ".join([ "%s%s:%s%s"%(self.tdtc(t),
                                            t,
-                                           self.tc(t),
-                                           self.td(t, v))
+                                           self.tdc(t),
+                                           self.tdr(t, v))
                               for (t,v) in o.items() ])
-            self.printer.out("%sid:%s%s %s%s"%(color["reset"], color["lblue"], id, tags, color["reset"]))
+            self.printer.out("%sid=%s%s %s%s"%(self.tdtc("id"), self.tdc("id"), tid, tags, color["reset"]))
 
 
 class Command_addtag(TqlCommand):
-- 
GitLab