-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathterminal_main.py
More file actions
44 lines (40 loc) · 1023 Bytes
/
terminal_main.py
File metadata and controls
44 lines (40 loc) · 1023 Bytes
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
'''
The executable for the CLI interface.
'''
from ConversationNode import ConversationNode
def test_conversation_print():
root = ConversationNode(user="Terminal", text="Hey, type a message.")
mid = ConversationNode("test1")
curr = ConversationNode("test2")
root.add(mid)
mid.add(curr)
curr.print_conversation()
def main():
root = ConversationNode(user="Terminal", text="Hey, type a message.")
root.print_conversation()
curr = root
i = 0
while True:
user_input = input("#BR,BK,MW,S,L>")
if user_input == "#BR":
break
elif user_input == "#BK":
if curr.parent:
curr = curr.parent
if curr.parent:
curr = curr.parent
elif user_input == "#MW":
print(root)
elif user_input == "#S":
root.save_conversation_tree()
elif user_input == "#L":
root = ConversationNode.load_conversation_tree()
curr = root
else:
ncurr = ConversationNode(user_input, f"User {i%2 + 1}")
i += 1
curr.add(ncurr)
curr = ncurr
curr.print_conversation()
if __name__ == "__main__":
main()