From fa3d7fa1dd41e526c5f944ad0190557d746d6b7c Mon Sep 17 00:00:00 2001 From: Hoffelhas Date: Sun, 7 Jun 2020 15:18:12 +0200 Subject: [PATCH] If the given label doesn't exists, a new one is now automatically created! --- autodoist.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autodoist.py b/autodoist.py index 5a1fcd9..0e6de6c 100644 --- a/autodoist.py +++ b/autodoist.py @@ -109,7 +109,7 @@ def main(): else: modes.append('Disabled') - logging.info("\nYou are running with the following functionalities:\n\n Next action labelling mode: {}\n Regenerate sub-tasks mode: {}\n Shifted end-of-day mode: {}\n".format(*modes)) + logging.info("You are running with the following functionalities:\n\n Next action labelling mode: {}\n Regenerate sub-tasks mode: {}\n Shifted end-of-day mode: {}\n".format(*modes)) if m_num == 0: logging.info("\n No functionality has been enabled. Please see --help for the available options.\n") @@ -137,14 +137,19 @@ def main(): else: # Create a new label in Todoist #TODO: - logging.error( - "\n\nLabel \'%s\' doesn't exist in your Todoist. Please create it or use your custom label by running Autodoist with the argument '-l '.\n", args.label) - sys.exit(1) + logging.info( + "\n\nLabel '{}' doesn't exist in your Todoist. A new label is now created for you.\n".format(args.label)) + # sys.exit(1) + api.labels.add(args.label) + api.commit() + api.sync() + labels = api.labels.all(lambda x: x['name'] == args.label) + label_id = labels[0]['id'] else: # Label functionality not needed label_id = None - logging.info("\nAutodoist has connected and is running fine!\n") + logging.info("Autodoist has connected and is running fine!\n") return api, label_id