Commit 05fb5e1a authored by Seblu's avatar Seblu
Browse files

addacount now use OptionCommand

parent 5549e95c
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -8,21 +8,22 @@ CloudControl accounts related commands
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
from cccli.command.command import Command, TqlCommand
from cccli.command.command import Command, OptionCommand, TqlCommand

class Command_addaccount(Command):
class Command_addaccount(OptionCommand):
    '''Create an account'''

    def __init__(self, cli, argv0):
        OptionCommand.__init__(self, cli, argv0)
        self.set_usage("%prog [options] <account name> <role>")

    def __call__(self, argv):
        if len(argv) != 3:
        # parse args
        self.parse_args(argv)
        if len(self.args) != 2:
            raise cmdBadArgument()
        try:
            self.cli.rpc.call("addaccount", argv[1], argv[2])
        except RpcError as e:
            raise cmdError("RPCError: %s"%str(e))

    def usage(self):
        return "Usage: addaccount <account name> <role>"
        # execute command
        self.rpccall("addaccount", self.args[0], self.args[1])


class Command_delaccount(TqlCommand):