-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
executable file
·118 lines (89 loc) · 2.32 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/python3
import os
import argparse
from commands import Commands
import traceback
from config import *
folder = ""
root = TODO_STORE_DIR + "/"
#--parser conf
parser = argparse.ArgumentParser(prog = 'todo-tracker',
description='Stores your work in a manageble list')
parser.add_argument('--store',
'--dmb',
nargs = '+',
action = 'store',
help = 'Stores an entry',
)
parser.add_argument('--delete',
action = 'store',
type = int,
help = 'Deletes an entry wrt its index'
)
parser.add_argument('--show',
action = 'store_true',
help = 'Shows Entries'
)
parser.add_argument('--purge',
action = 'store_true',
help = 'Deletes all entries'
)
parser.add_argument('--exit',
action = 'store_true',
help = 'Exits the application'
)
parser.add_argument('--search',
'--data',
nargs = '+',
help = 'Searches an entry'
)
parser.add_argument('--cd',
action='store',
nargs = '+',
help = 'Changes subject/directory'
)
parser.add_argument('--ls',
action = 'store_true',
help='Displays existing folders'
)
#--
#main function which reads the inputted commands
def run(command):
if(command=="\\"):
return 0
args = command.split()
command_handler = Commands(root, args[1:])
commands = command_handler.get_dict()
try:
return commands[args[0]]()
except KeyError:
print("This command doesnt exist, try these : \n"+"\n".join(commands.keys()))
return 1;
subject=os.popen("cat curr_dir").read()
root+=subject
if folder == 'todo':
is_todo = 1
if not os.path.exists(root):
os.makedirs(root)
args, leftovers = parser.parse_known_args()
command = ''
data = ''
if args.store is not None:
command = 'store'
data = " ".join(args.store)
elif args.delete is not None:
command = 'delete'
data = args.delete
elif args.purge:
command = 'purge'
elif args.show:
command = 'show'
elif args.search is not None:
command = 'search'
data = " ".join(args.search)
elif args.cd is not None:
command = 'cd'
data = args.cd[0]
elif args.ls:
command = 'ls'
run("%s %s"%(command, data))