-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLI.py
30 lines (27 loc) · 989 Bytes
/
CLI.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
from functions import get,writetodo,complete
file = open('todos.txt','w')
file.close()
while True:
user_input = input("Enter Action : ").split(" ",1)
match user_input[0].lower():
case 'add':
writetodo(user_input[1]+'\n')
case 'show':
for no,todo in enumerate(get()):
todo = todo.strip("\n")
print(f"{no+1}-{todo}")
case 'complete':
complete(user_input[1].lower()+'\n')
case 'edit':
content = get()
for i in content:
if user_input[1].lower() == i.strip('\n'):
new_input = input("Enter New to-do : ")
content[content.index(i)] = new_input+'\n'
with open("todos.txt","w") as filehandler:
filehandler.writelines(content)
case "exit":
print('Bye!')
break
case _:
print("Enter valid to-dos")