-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (54 loc) · 2.05 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
from rich import print
from pathlib import Path
from rich.align import Align
from rich.panel import Panel
from data.list import choices
from rich.prompt import Prompt
from typing import Callable, Dict
from data.side_functions import SideFunctions
from data.main_functions import MainFunctions
side_functions = SideFunctions()
main_functions = MainFunctions(side_functions)
def exit_program() -> None:
print(Align.center("[bold red]Exiting..."))
exit(1)
def main() -> None:
commands: Dict[str, Callable[[], None]] = {
"settings": main_functions.display_settings,
"status": main_functions.check_link_statuses,
"quit": exit_program,
}
while True:
os.system("cls" if os.name == "nt" else "clear")
print(
Align.center(
Panel(
main_functions.table_gen(),
title="Available Downloads",
subtitle=f"Multi-Installer v{side_functions.get_version()}",
style="bold purple",
border_style="bold green",
)
)
)
print(
Align.center(
"\n[bold white][[bold yellow]settings[bold white]] [bold cyan]Modify settings\n[bold white][[bold yellow]status[bold white]] [bold cyan]Check link availability\n[bold white][[bold yellow]quit[bold white]] [bold red]Exit"
)
)
user_choice = Prompt.ask(
"\n[bold white][[bold yellow]>[bold white]] [bold cyan]Choice"
)
if user_choice.lower() in commands:
commands[user_choice.lower()]()
elif user_choice not in choices.keys():
print(Align.center(f"[bold red]Invalid choice"))
return main()
elif user_choice in choices.keys():
main_functions.download_and_run(user_choice)
main_functions.clean_up_files(user_choice, Path(__file__).resolve().parent)
if __name__ == "__main__":
os.system("cls" if os.name == "nt" else "clear")
side_functions.clean_up_cache()
main()