def main(): """ main UI function """ todo_list = Todo() while True: cmd, args = ask_option() cmd = cmd.lower() try: if cmd == "add": todo_list.add(args) elif cmd == "del": todo_list.remove(args) elif cmd == "ls" and args: print(todo_list.show(args)) elif cmd == "ls": for todo in todo_list.show_all(): print(todo) elif cmd == "save": todo_list.save(args) elif cmd == "load": todo_list.load(args) elif cmd == "help": print(HELPER) elif cmd == "q": break else: print("Invalid option") except Exception as err: print("ERROR: " + str(type(err)) + " - " + str(err))
def todo(): todos = Todo() if len(sys.argv) == 1: print('Incorrect usage!') else: cmd = sys.argv[1] if cmd == 'add': name = sys.argv[2] todos.add(name) elif cmd == 'remove': id = sys.argv[2] todos.remove(id) elif cmd == 'show': todos.show() elif cmd == 'done': id = sys.argv[2] todos.done(id) elif cmd == 'undone': id = sys.argv[2] todos.undone(id) elif cmd == 'clear': todos.clear() todos.save()
mlab.connect() loop = True while loop: print('''1. New todo 2. View ALL Todos 3. Mark a Todo COMPLETED 4. Delete a Todo 5. Exit''') cmd = input("Enter your command? ").upper() if cmd == "1": name = input("Name: ") description = input("Description: ") new_todo = Todo(name=name, description=description) new_todo.save() elif cmd == "2": print("= " * 20) if Todo.objects().count() == 0: print("EMPTY") else: todo_list = Todo.objects() todo_no = 1 for todo in todo_list: print(todo_no, todo, sep=". ") todo_no += 1 print() print("= " * 20) elif cmd == "3": i = int(input("Which one? ")) - 1 todo_list = Todo.objects()
mlab.connect() string = ''' 1. New todo 2. View All Todos 3. Mark a Todo Completed 4. Delete a todo 5. Exit Enter your Command? ''' user = int(input(string)) if user == 1: n = input("Name: ") d = input("Description: ") t = Todo(name=n, description=d) t.save() elif user == 2: todo_list = Todo.objects() if len(todo_list) != 0: for i in todo_list: print(i.name, i.description, sep='\n') else: print("Empty") elif user == 3: index = int(input("Which one? ")) print("Updated") records = Todo.objects() for r in records: if r == index: r.update(set__available=True) elif user == 4: