From e9d51f4e5c48a801fcab542b9d3b8e55f1de1355 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 10 Feb 2011 13:12:20 +0100
Subject: [PATCH] server now report server version

---
 cccli/command/server.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/cccli/command/server.py b/cccli/command/server.py
index 3ce28ad..94ee3fa 100644
--- a/cccli/command/server.py
+++ b/cccli/command/server.py
@@ -19,23 +19,28 @@ class Command_server(OptionCommand):
                                 help="show server cache")
         self.option.add_option("-l", action="store_true", dest="commands",
                                 help="list server commands")
+        self.option.add_option("-v", action="store_true", dest="version",
+                                help="show server version")
+
 
     def __call__(self, argv):
         try:
             (options, args) = self.option.parse_args(argv[1:])
         except SystemExit:
             return
-        if len(args) > 0 or (not options.cache and not options.commands):
+        if len(args) > 0:
             self.printer.out(self.usage())
-            return
-        if options.cache:
+        elif options.cache:
             self.show_cache()
-        if options.commands:
+        elif options.commands:
             self.show_commands()
+        elif options.version:
+            self.show_version()
+        else:
+            self.printer.out(self.usage())
 
     def show_commands(self):
         try:
-            self.printer.out("%sServer commands:%s"%(color["lblue"], color["reset"]))
             for cmds in self.cli.rpc.call("list_commands"):
                 self.printer.out("%s"%cmds["name"])
         except RpcError as e:
@@ -43,9 +48,14 @@ class Command_server(OptionCommand):
 
     def show_cache(self):
         try:
-            self.printer.out("%sServer cache:%s"%(color["lblue"], color["reset"]))
             d = self.cli.rpc.call("dbstats")
             for i,v in d.items():
                 self.printer.out("%s: %s"%(i,v))
         except RpcError as e:
             raise cmdError("RPCError: %s"%str(e))
+
+    def show_version(self):
+        try:
+            self.printer.out(self.cli.rpc.call("version"))
+        except RpcError as e:
+            raise cmdError("RPCError: %s"%str(e))
-- 
GitLab