[spp] [PATCH 12/13] controller: add cat and less command
ogawa.yasufumi at lab.ntt.co.jp
ogawa.yasufumi at lab.ntt.co.jp
Tue Mar 6 11:50:54 CET 2018
From: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi at lab.ntt.co.jp>
---
src/controller/shell.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 8aae86d..86598d3 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -468,6 +468,34 @@ class Shell(cmd.Cmd, object):
]
return completions
+ def do_cat(self, arg):
+ """View contents of a file
+
+ spp > cat file
+ """
+ if os.path.isfile(arg):
+ c = 'cat %s' % arg
+ subprocess.call(c, shell=True)
+ else:
+ print("No such a directory.")
+
+ def complete_cat(self, text, line, begidx, endidx):
+ return common.compl_common(text, line)
+
+ def do_less(self, arg):
+ """View contents of a file
+
+ spp > less file
+ """
+ if os.path.isfile(arg):
+ c = 'less %s' % arg
+ subprocess.call(c, shell=True)
+ else:
+ print("No such a directory.")
+
+ def complete_less(self, text, line, begidx, endidx):
+ return common.compl_common(text, line)
+
def do_exit(self, args):
"""Terminate SPP controller
--
2.13.1
More information about the spp
mailing list