Skip to content

Commit c667eee

Browse files
committed
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>
1 parent fb57cee commit c667eee

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tools/cli/cloudmonkey/cloudmonkey.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
# Licensed to the Apache Software Foundation (ASF) under one
44
# or more contributor license agreements. See the NOTICE file
@@ -428,7 +428,13 @@ def grammar_closure(self, args):
428428
if '--help' in args:
429429
self.print_shell(res[2])
430430
return
431-
self.default(res[0] + " " + args_partition[2])
431+
if '|' in args:
432+
prog_name = sys.argv[0]
433+
if '.py' in prog_name:
434+
prog_name = "python " + prog_name
435+
self.do_shell("%s %s %s" % (prog_name, rule, args))
436+
else:
437+
self.default(res[0] + " " + args_partition[2])
432438
return grammar_closure
433439

434440
grammar_handler = add_grammar(rule)

0 commit comments

Comments
 (0)