From d0f9610355286388013f2d84faa02e158c131678 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 6 Nov 2012 14:23:19 +0530 Subject: [PATCH] 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 --- tools/cli/cloudmonkey/cloudmonkey.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index 8b986f9f680..13e02521370 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]