def main(): (option, query) = alfred.args2() if option == "-c": itemlist.clear_todos() elif option == "-a": actionize(query) elif option == "-q": process_todo_query(query) elif option == "-r": itemlist.remove_item(query) elif option == "-v": itemlist.retrieve_and_store_tag(query) elif option == '-p': if helpers.is_todo(query): itemlist.toggle_pinned(helpers.extract_todo_id(query))
def main(): (option, query) = alfred.args2() option_actions = { # Clearing items '-c': lambda q: itemlist.clear_all_todos(), '-ct': lambda q: itemlist.clear_todos(done=False), '-cd': lambda q: itemlist.clear_todos(done=True), # Processing query input '-a': lambda q: actionize(q), '-q': lambda q: process_todo_query(q), '-r': lambda q: itemlist.remove_item(q), # Item toggles '-p': lambda q: toggle_pin(q), '-d': lambda q: toggle_done(q) } option_actions[option](query) config.commit()