-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.py
executable file
·50 lines (37 loc) · 1.14 KB
/
sample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
from friendlyshell.basic_shell import BasicShell
class MySubShell(BasicShell):
def __init__(self, *args, **kwargs):
super(MySubShell, self).__init__(*args, **kwargs)
self.prompt = "(child)> "
def do_sub_op(self):
print("Child sub op1")
class MyShell (BasicShell):
def __init__(self, *args, **kwargs):
super(MyShell, self).__init__(*args, **kwargs)
self.banner_text = "My Sample Shell v1.0"
def complete_parent_op(self, params, index):
# print("In completer...")
self.debug(str(params))
self.debug(str(index))
options = [
"Hello",
"Howdy",
"HellNo",
"World",
"FuBar",
"Johnathan",
"JohnDoe",
]
return [i for i in options if i.startswith(params[index])]
def do_parent_op(self):
print("Parent op1")
def do_subshell(self):
tmp = MySubShell()
return self.run_subshell(tmp)
if __name__ == "__main__":
obj = MyShell()
# obj.run()
# exit()
with open("test.fsh", "r") as fh:
obj.run(input_stream=fh)