cli: add feature to cache docstrings for an api

cached verb dictionary stores the following as a list:
- name of the API
- params (list of args)
- docstring

Signed-off-by: Rohit Yadav <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/d0f96103
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/d0f96103
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/d0f96103

Branch: refs/heads/master
Commit: d0f9610355286388013f2d84faa02e158c131678
Parents: 00d5c3f
Author: Rohit Yadav <[email protected]>
Authored: Tue Nov 6 14:23:19 2012 +0530
Committer: Rohit Yadav <[email protected]>
Committed: Tue Nov 6 14:28:39 2012 +0530

----------------------------------------------------------------------
 tools/cli/cloudmonkey/cloudmonkey.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d0f96103/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py 
b/tools/cli/cloudmonkey/cloudmonkey.py
index 8b986f9..13e0252 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -266,12 +266,15 @@ class CloudStackShell(cmd.Cmd):
             try:
                 api_cmd_str = "%sCmd" % api_name
                 api_mod = self.get_api_module(api_name, [api_cmd_str])
-                api_cmd = getattr(api_mod, api_cmd_str)
+                api_cmd = getattr(api_mod, api_cmd_str)()
                 doc = api_mod.__doc__
             except AttributeError, e:
                 self.print_shell("Error: API attribute %s not found!" % e)
             params = filter(lambda x: '__' not in x and 'required' not in x,
-                            dir(api_cmd()))
+                            dir(api_cmd))
+            if len(api_cmd.required) > 0:
+                doc += "\nRequired args: %s" % " ".join(api_cmd.required)
+            doc += "\nArgs: %s" % " ".join(params)
             api_name_lower = api_name.replace(verb, '').lower()
             self.cache_verbs[verb][api_name_lower] = [api_name, params, doc]
 

Reply via email to