-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (54 loc) · 1.59 KB
/
main.py
File metadata and controls
62 lines (54 loc) · 1.59 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
62
import sys
import os
import signal
# import modules
from modules.help_messages import usage_message
from modules.init import init_abcmn_dir
from modules.stats import handle_stats_command
from modules.tasks import handle_tasks_command
from modules.timer import handle_timer_command
from modules.utils import exit_gracefully
from modules.version import __version__ as app_version
from modules.push import handle_push_command
# abcmn cli tool entry point
# read the README.md file for the tool usage information
def main():
argv = sys.argv
argc = len(argv)
if argc < 2:
print(usage_message)
sys.exit(1)
# handle SIGINT and SIGTERM signals
signal.signal(signal.SIGINT, exit_gracefully)
signal.signal(signal.SIGTERM, exit_gracefully)
if argv[1] == "init":
init_abcmn_dir()
sys.exit(0)
if argv[1] == "help":
print(usage_message)
sys.exit(0)
elif argv[1] == "version":
print(f"Version: {app_version}")
sys.exit(0)
__abcmn_dir = os.path.join(".abcmn")
if not os.path.exists(__abcmn_dir):
print("Please run 'abcmn init' to initialize the tool")
sys.exit(1)
if argv[1] == "push":
handle_push_command(argv)
elif argv[1] == "tasks":
handle_tasks_command(argv)
elif argv[1] == "timer":
handle_timer_command(argv)
elif argv[1] == "stats":
handle_stats_command()
else:
print(usage_message)
sys.exit(1)
sys.exit(0)
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"Error: {e}")
sys.exit(1)