cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject cloudstack-cloudmonkey git commit: cloudmonkey: zsh styled history invocation using !
Date Fri, 08 Jan 2016 16:58:12 GMT
Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master ae8020bd8 -> f5c7c691b


cloudmonkey: zsh styled history invocation using !

- Can run historic command with history !<num> or just !<num> on the shell
- Instead of running the history command, print on prompt and waits for user
  action
- history c or history clear to clear history

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/master
Commit: f5c7c691b5f2b8e905ed7fc28f73a36854060576
Parents: ae8020b
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Fri Jan 8 22:26:11 2016 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Fri Jan 8 22:26:11 2016 +0530

----------------------------------------------------------------------
 CHANGES.md                 |  5 +++++
 Dockerfile                 |  2 +-
 cloudmonkey/cloudmonkey.py | 18 +++++++++++++++++-
 cloudmonkey/config.py      |  2 +-
 docs/source/conf.py        |  2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f5c7c691/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 1990a9c..113e8cc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,11 @@
 Apache CloudStack CloudMonkey Changelog
 ---------------------------------------
 
+Version 5.3.3
+=============
+This release includes
+- Support for shell history
+
 Version 5.3.2
 =============
 This release includes

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f5c7c691/Dockerfile
----------------------------------------------------------------------
diff --git a/Dockerfile b/Dockerfile
index 989e832..696974d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -22,7 +22,7 @@ MAINTAINER "Apache CloudStack" <dev@cloudstack.apache.org>
 LABEL Description="Apache CloudStack CloudMonkey; Python based CloudStack command line interface"
 LABEL Vendor="Apache.org"
 LABEL License=ApacheV2
-LABEL Version=5.3.2
+LABEL Version=5.3.3
 
 COPY . /cloudstack-cloudmonkey
 RUN pip install requests

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f5c7c691/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index ebd540b..1a643e4 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -93,6 +93,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
     host = "localhost"
     port = "8080"
     path = "/client/api"
+    hook_count = 0
 
     def __init__(self, pname, cfile):
         self.program_name = pname
@@ -152,6 +153,13 @@ class CloudMonkeyShell(cmd.Cmd, object):
             except KeyboardInterrupt:
                 print("^C")
 
+    def precmd(self, line):
+        self.hook_count -= 1
+        if self.hook_count <= 0:
+            self.hook_count = 0
+            readline.set_startup_hook()
+        return line
+
     def loadcache(self):
         if os.path.exists(self.cache_file):
             self.apicache = loadcache(self.cache_file)
@@ -718,6 +726,9 @@ class CloudMonkeyShell(cmd.Cmd, object):
             email=test@test.tt firstname=user$i lastname=user$i \
             password=password username=user$i; done
         """
+        if args.isdigit():
+            self.do_history("!" + args)
+            return
         if isinstance(args, str):
             os.system(args)
         else:
@@ -737,10 +748,15 @@ class CloudMonkeyShell(cmd.Cmd, object):
             startIdx = endIdx - long(historyArg)
             if startIdx < 1:
                 startIdx = 1
-        elif historyArg == "clear":
+        elif historyArg == "clear" or historyArg == "c":
             readline.clear_history()
             print "CloudMonkey history cleared"
             return
+        elif len(historyArg) > 1 and historyArg[0] == "!" and historyArg[1:].isdigit():
+            command = readline.get_history_item(long(historyArg[1:]))
+            readline.set_startup_hook(lambda: readline.insert_text(command))
+            self.hook_count = 1
+            return
         for idx in xrange(startIdx, endIdx):
             self.monkeyprint("%s %s" % (str(idx).rjust(numLen),
                                         readline.get_history_item(idx)))

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f5c7c691/cloudmonkey/config.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/config.py b/cloudmonkey/config.py
index 4f55382..c5faec2 100644
--- a/cloudmonkey/config.py
+++ b/cloudmonkey/config.py
@@ -16,7 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-__version__ = "5.3.2"
+__version__ = "5.3.3"
 __description__ = "Command Line Interface for Apache CloudStack"
 __maintainer__ = "The Apache CloudStack Team"
 __maintaineremail__ = "dev@cloudstack.apache.org"

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/f5c7c691/docs/source/conf.py
----------------------------------------------------------------------
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 669bd31..9c30ccb 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -55,7 +55,7 @@ copyright = u'2012-2014, The Apache Software Foundation'
 # built documents.
 #
 # The short X.Y version.
-version = '5.3.2'
+version = '5.3.3'
 # The full version, including alpha/beta/rc tags.
 release = version
 


Mime
View raw message