diff options
Diffstat (limited to 'todoist')
-rwxr-xr-x | todoist | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -32,6 +32,10 @@ def arg_parser(): help="Severity (or priority) of task", type=int, choices=[1, 2, 3, 4]) + parser.add_argument("-a", "--assign", + metavar="NAME", + help="Assign to collaborator", + type=str) parser.add_argument("-d", "--date", metavar="DATE", help="Date string", @@ -64,6 +68,10 @@ def build_project_list(data): projects = { proj["name"].lower(): proj["id"] for proj in data["Projects"] } return projects +def build_collaborators_list(data): + collaborators = { col["full_name"].lower(): col["id"] for col in data["Collaborators"] } + return collaborators + def main(): args = arg_parser() @@ -94,6 +102,7 @@ def main(): sys.exit(0) projects = build_project_list(data) + collaborators = build_collaborators_list(data) ## Prepare data if not args.msg: @@ -105,14 +114,27 @@ def main(): kwargs = {} kwargs["date_string"] = args.date if args.project: - if args.project in projects: - kwargs["project_id"] = projects[args.project] + proj = args.project.lower() + if proj in projects: + kwargs["project_id"] = projects[proj] else: print("WARNING: Unknown project. Task will be stored in Inbox", file=sys.stderr) if args.severity: kwargs["priority"] = args.severity + if args.assign: + name = args.assign.lower() + aid = None + for k, v in collaborators.items(): + if k.find(name) != -1: + aid = v + break + if not aid: + print("ERROR: Unknown person", file=sys.stderr) + sys.exit(1) + kwargs["responsible_uid"] = aid + ## Store task status = api.add_item(msg, **kwargs) if "error" in status: |