-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (52 loc) · 1.74 KB
/
Copy pathmain.py
File metadata and controls
61 lines (52 loc) · 1.74 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
50
51
52
53
54
55
56
57
58
59
60
61
import sys
import asyncio
from main_select_courses import main_select_courses
from inquire_course_info import inquire_course_info
from verify_cookie_validity import verify_cookie_validity
from check_course import check_course
from config_loader import add_courses_directly
def display_help():
"""
Show Commands
"""
print("Usage: python main.py <command>")
print("Commands:")
print(" --start : Select courses for all users")
print(" [--endless] Retry indefinitely until successful")
print(" --inquire : Inquire course info")
print(" --add : Add known course IDs to config")
print(" --validate : Batch validate cookie validity")
print(" --check : Verify course availability")
print(" --help : Show this help message and exit")
async def main():
args = sys.argv
if len(args) < 2:
display_help()
return
match args[1].lower():
case "--start":
if len(args) > 2 and args[2].lower() == "--endless":
print("Entering ENDLESS mode.")
await main_select_courses(endless=True)
else:
await main_select_courses()
case "--inquire":
await inquire_course_info()
case "--add":
add_courses_directly()
case "--validate":
await verify_cookie_validity()
case "--check":
await check_course()
case "--help" | "-h":
display_help()
case _:
print("Error: Unknown command.")
display_help()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
finally:
print("Exiting application.")