-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (37 loc) · 1.06 KB
/
main.py
File metadata and controls
49 lines (37 loc) · 1.06 KB
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
import config.terminal as terminal
import server.host as host
import client.client as client
def select_mode():
"""Prompt the user to select a mode (Host or Client)"""
mode = input("Select your mode:\n[H]ost\n[C]lient\n: ").strip()
if not mode:
print("Error: No mode selected.")
return None
return mode[0].lower()
def run():
mode = select_mode()
if mode is None:
return
terminal.clear_screen()
if mode not in ("h", "c"):
print("Error: Invalid mode selected. Please choose 'H' for Host or 'C' for Client.")
return
match mode:
case "h":
print("Host mode selected")
terminal.clear_screen()
host.run()
case "c":
print("Client mode selected")
terminal.clear_screen()
client.run()
if __name__ == "__main__":
terminal.enter_alt_screen()
try:
run()
print("Press enter to continue", end="")
terminal.pause()
except:
pass
finally:
terminal.exit_alt_screen()