diff --git a/cccli/command/right.py b/cccli/command/right.py index cf99069f27ff00ce8252760d8d7c7c087b0cb6e6..005c3de09c08aba9a016d7708547c861592c5379 100644 --- a/cccli/command/right.py +++ b/cccli/command/right.py @@ -8,20 +8,21 @@ CloudControl right 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_rights(Command): +class Command_rights(OptionCommand): '''List account rights''' + 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 @@ -44,9 +45,6 @@ class Command_rights(Command): tags = " ".join([ "%s%s:%s%s"%(color["green"], t, color["reset"], v) for (t,v) in r.items() ]) self.printer.out("[%s] %s"%(i,tags)) - def usage(self): - return "Usage: rights [--raw] [--help] [tql]" - class Command_addright(Command): '''Add or edit account right'''