-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.py
48 lines (36 loc) · 987 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from PyInquirer import prompt
todos = ['Learn python', 'Learn JavaScript']
def show_todos():
print('All my todos 👉')
for item in todos:
print(f'🔮 {item}')
def add_new_todo(task):
todos.append(task)
def show_add_todo_prompt():
question = {
'type': 'input',
'name': 'task',
'message': 'What is your new task?',
}
answer = prompt(question)
add_new_todo(answer['task'])
def main():
question = {
'type': 'input',
'name': 'command',
'message': 'What you want to do next (list/add/exit) >>',
}
answer = prompt(question)
if answer['command'] == 'list':
show_todos()
elif answer['command'] == 'add':
show_add_todo_prompt()
show_todos()
elif answer['command'] == 'exit':
exit()
else:
print('❗️ You entered unavailable task, please enter again!')
main()
if __name__ == "__main__":
print("My todos list.")
main()