diff --git a/cccli/command/tag.py b/cccli/command/tag.py index e38ef9be2fc5fbda7b712f890c45b8fd7a417c83..cda438c1dc7bbd9aa52ac0b2f48a9f6150d78d68 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):