From 05fb5e1ab7396afff32d591c20e73512f4962cb3 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Mon, 14 Feb 2011 11:45:20 +0100
Subject: [PATCH] addacount now use OptionCommand

---
 cccli/command/account.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/cccli/command/account.py b/cccli/command/account.py
index 619b653..0734ea8 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):
-- 
GitLab