Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/5.3 300c47534 -> d835341e9


cloudmonkey: fix readline issue across OSX and Linux

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


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

Branch: refs/heads/5.3
Commit: d835341e9feec63695a112f092289c8ec7ac972a
Parents: 300c475
Author: Rohit Yadav <[email protected]>
Authored: Sat Nov 1 00:36:28 2014 +0530
Committer: Rohit Yadav <[email protected]>
Committed: Sat Nov 1 00:36:28 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/d835341e/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 117e157..2c48af7 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -51,6 +51,7 @@ try:
 except ImportError:
     apicache = {'count': 0, 'verbs': [], 'asyncapis': []}
 
+normal_readline = True
 try:
     import readline
 except ImportError, e:
@@ -60,6 +61,7 @@ else:
     if 'libedit' in readline.__doc__:
         readline.parse_and_bind("bind ^I rl_complete")
         readline.parse_and_bind("bind ^R em-inc-search-prev")
+        normal_readline = False
     else:
         readline.parse_and_bind("tab: complete")
 
@@ -439,8 +441,13 @@ class CloudMonkeyShell(cmd.Cmd, object):
                     suffix = ",".join(used)
                     if suffix:
                         suffix += ","
-                    return filter(lambda x: x.startswith(value),
-                                  map(lambda x: suffix + x, unused))
+                    global normal_readline
+                    if normal_readline:
+                        return filter(lambda x: x.startswith(last_value),
+                                      map(lambda x: x, unused))
+                    else: # OSX fix
+                        return filter(lambda x: x.startswith(value),
+                                      map(lambda x: suffix + x, unused))
                 elif len(value) < 36 and idx != -1:
                     api = None
                     logger.debug("[Paramcompl] For %s %s %s=" % (verb, subject,

Reply via email to