diff --git a/cccli/command/account.py b/cccli/command/account.py index 619b653caea3c0fa5d3594ad5f39243bc00ec528..0734ea8f3bd8b0d9eb4221c91131f362dea1b73b 100644 --- a/cccli/command/account.py +++ b/cccli/command/account.py @@ -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):