You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/11/06 10:34:16 UTC

[2/5] git commit: cli: add autocompletion and dynamic help doc

cli: add autocompletion and dynamic help doc

- autocompletions for help docs
- more verbose doc strings with __doc__ import from the module and list of
  required args and all args

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/master
Commit: 9e6b366023ace3dab5b85b93412a1b1c3667d3a2
Parents: a1089c4
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Nov 6 14:26:40 2012 +0530
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Nov 6 14:28:40 2012 +0530

----------------------------------------------------------------------
 tools/cli/cloudmonkey/cloudmonkey.py |   30 +++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9e6b3660/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index dc20f22..8e4a79c 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -346,6 +346,36 @@ class CloudStackShell(cmd.Cmd):
         """
         os.system(args)
 
+    def do_help(self, args):
+        """
+        Show help docs for various topics
+
+        Example:
+        help list
+        help list users
+        ?list
+        ?list users
+        """
+        fields = args.partition(" ")
+        if fields[2] == "":
+            cmd.Cmd.do_help(self, args)
+        else:
+            verb = fields[0]
+            subject = fields[2].partition(" ")[0]
+            if verb not in self.cache_verbs:
+                self.cache_verb_miss(verb)
+            self.print_shell(self.cache_verbs[verb][subject][2])
+
+    def complete_help(self, text, line, begidx, endidx):
+        fields = line.partition(" ")
+        subfields = fields[2].partition(" ")
+
+        if subfields[1] != " ":
+            return cmd.Cmd.complete_help(self, text, line, begidx, endidx)
+        else:
+            line = fields[2]
+            text = subfields[2]
+            return self.completedefault(text, line, begidx, endidx)
 
     def do_quit(self, args):
         """