-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (39 loc) · 1.14 KB
/
main.py
File metadata and controls
43 lines (39 loc) · 1.14 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
import os
import logging
import sys
import src.util as util
import src.io as io
def check_config()-> None:
if not os.path.exists("accounts.toml"):
logging.error("accounts.toml not found. Try to copy accounts.toml.example to accounts.toml and edit it")
exit(1)
logging.info("accounts.toml found")
def main()-> None:
check_config()
print("=" * 20)
print("CAU Auto Signin Program")
print("=" * 20)
match sys.argv[1]:
case "help":
util.help()
case "now":
util.now()
case "logout":
util.logout()
case "auto-select":
util.auto_select()
case "login":
if len(sys.argv) != 3:
logging.error("Usage: uv run main.py login [NUMBER]")
exit(1)
try:
account_id = int(sys.argv[2])
except ValueError:
logging.error("Invalid account id: {sys.argv[2]}")
exit(1)
util.login(account_id)
case _:
logging.error(f"Unknown command: {sys.argv[1]}")
util.help()
if __name__ == "__main__":
main()