This repository has been archived by the owner on Mar 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
57 lines (53 loc) · 1.93 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
import argparse
import sys
import os
from project import check as c
from project import submit as s
from project import make_project as p
from project.freezerestore import freeze as f
from project.freezerestore import restore as r
import sqlite3
def main():
if __name__ == "__main__":
# setup sqlite server
conn = sqlite3.connect('projects.db')
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS projects
(name text, duedate text, course text, semester text, assignment text, path text)''')
parser = argparse.ArgumentParser()
parser.add_argument("operation", action="store", type=str)
parser.add_argument("--argname", default="", action="store", type=str)
arg = parser.parse_args()
if arg.operation == "project":
if arg.argname == "":
print("Creating project...")
p.make_project()
sys.exit(0)
else:
print("Creating project...")
p.make_project(arg.argname)
sys.exit(0)
elif arg.operation == "check":
print("Checking project status...")
c.check()
sys.exit(0)
elif arg.operation == "submit":
print("Opening submit link...")
s.submit("")
sys.exit(0)
elif arg.operation == "freeze":
if arg.argname == "":
print("You didn't input a file name!")
else:
print("Freezing file " + arg.argname + ".")
f.freeze(arg.argname)
sys.exit(0)
elif arg.operation == "restore":
if arg.argname == "":
print("You didn't input a file name!")
else:
print("Restoring file " + arg.argname + ".")
r.restore(arg.argname)
sys.exit(0)
else:
print("Command not found.")