From d0eb1cf158dad07efbbcac3b40785444558777dc Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Tue, 8 Feb 2011 11:51:42 +0100 Subject: [PATCH] improve tags command --- cccli/command/tag.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cccli/command/tag.py b/cccli/command/tag.py index f5b03f4..4f85651 100644 --- a/cccli/command/tag.py +++ b/cccli/command/tag.py @@ -8,20 +8,23 @@ CloudControl tag releated commands from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color -from cccli.command.command import Command +from cccli.command.command import Command, OptionCommand from optparse import OptionParser -class Command_tags(Command): - '''List static tags on an account (current by default)''' +class Command_tags(OptionCommand): + '''List static tags on an account''' + + def __init__(self, cli, argv0): + OptionCommand.__init__(self, cli, argv0) + self.option.set_usage("%prog [options] [tql]") + self.option.add_option("--raw", action="store_true", dest="raw", + help="Don't append filter on request") def __call__(self, argv): # Parse argline try: - oparser = OptionParser(prog=argv[0]) - oparser.add_option("--raw", action="store_true", dest="raw", - help="Don't append filter on request") - (options, args) = oparser.parse_args(argv[1:]) + (options, args) = self.option.parse_args(argv[1:]) except SystemExit: return # append current login if nothing asked @@ -43,9 +46,6 @@ class Command_tags(Command): tags = " ".join([ "%s%s:%s%s"%(color["green"], t, color["reset"], v) for (t,v) in o.items() ]) self.printer.out("%sid:%s%s%s %s"%(color["green"], color["yellow"], id, color["reset"], tags)) - def usage(self): - return "Usage: tags [--raw] [--help] [tql]" - class Command_addtag(Command): '''Add/Modify a static tag on an account''' -- GitLab