-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
64 lines (56 loc) · 2.02 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
import signal, sys
import argparse
import logging
from run import shlok_ai_terminal
from run import shlok_ai_web
def signal_handler(signal, frame):
print("You have requested to exit the program using Ctrl+C. Exiting.")
logging.info("You have requested to exit the program using Ctrl+C. Exiting.")
sys.exit(0)
def accept_user_input():
# try:
# parser = argparse.ArgumentParser(description="Choose the mode to run ShlokAI")
# parser.add_argument("-t", "--terminal", help="Run ShlokAI in Terminal mode")
# parser.add_argument("-w", "--web", help="Run ShlokAI in Web mode")
# # args = parser.parse_args()
# except Exception as er:
# print(er)
# logging.critical(er)
# return
help_message = """
usage: main.py [-h] [-t] [-w]
Choose the mode to run ShlokAI
options:
-h, --help show this help message and exit
-t, --terminal Run ShlokAI in Terminal mode
-w, --web Run ShlokAI in Web mode
"""
if len(sys.argv) == 1:
print(
"Please choose a mode to run ShlokAI. View Help menu for modes: python main.py -h"
)
logging.critical(
"Please choose a mode to run ShlokAI. View Help menu for modes: python main.py -h"
)
return
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
print(help_message)
logging.info(help_message)
return
elif sys.argv[1] == "-t" or sys.argv[1] == "--terminal":
shlok_ai_terminal.shlokAI()
elif sys.argv[1] == "-w" or sys.argv[1] == "--web":
shlok_ai_web.shlokAI()
# if args.terminal:
# shlok_ai_terminal.shlokAI()
# elif args.web:
# shlok_ai_web.shlokAI()
else:
print("Please choose a mode to run ShlokAI")
logging.critical(
"Please choose a mode to run ShlokAI. View Help menu for modes: python main.py -h"
)
return
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
accept_user_input()