incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [47/100] [abbrv] git commit: cli: make commands pipe-able as on bash, on the shell
Date Thu, 06 Dec 2012 08:09:11 GMT
cli: make commands pipe-able as on bash, on the shell

Makes commands pipe-able like bash.
Example while inside shell:
  > list virtualmachines | grep id
  > list accounts | more

Signed-off-by: Rohit Yadav <bhaisaab@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/c667eee5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c667eee5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c667eee5

Branch: refs/heads/events-framework
Commit: c667eee570492fd2a382f5a69acdb4aa121fb7de
Parents: fb57cee
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Thu Nov 8 12:26:54 2012 +0530
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Thu Nov 8 12:35:20 2012 +0530

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


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c667eee5/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index 7a42b0b..83bd8c1 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 # -*- coding: utf-8 -*-
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -428,7 +428,13 @@ def main():
                 if '--help' in args:
                     self.print_shell(res[2])
                     return
-                self.default(res[0] + " " + args_partition[2])
+                if '|' in args:
+                    prog_name = sys.argv[0]
+                    if '.py' in prog_name:
+                        prog_name = "python " + prog_name
+                    self.do_shell("%s %s %s" % (prog_name, rule, args))
+                else:
+                    self.default(res[0] + " " + args_partition[2])
             return grammar_closure
 
         grammar_handler = add_grammar(rule)


Mime
View raw message