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()
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))
from todo import Todo import sys app = Todo() params = sys.argv if len(params) <= 1: app.help() sys.exit() command = params[1] if command == 'add': app.add(params) elif command in ('today', 'day', 'to'): app.today(params) elif command in ('show', 'list'): app.show(params) elif command in ('delete', 'remove'): app.delete(params) elif command in ('mark', 'done'): app.mark_done(params) elif command == 'help': app.help() else: app.help()