Skip to content

Instantly share code, notes, and snippets.

@linuxcaffe
Forked from wbsch/on-add_annotate.py
Created June 1, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linuxcaffe/c9975c999144e96a220fa06d8d7d7c6e to your computer and use it in GitHub Desktop.
Save linuxcaffe/c9975c999144e96a220fa06d8d7d7c6e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
#
# Save as on-add_annotate.py in hooks directory, then:
# $ chmod +x ~/.task/hooks/on-add_annotate.py
#
# Anything after "annotate:" in a new task's description is added as an
# annotation:
# $ task add this is the description annotate:this is an annotation
import json
import sys
task = json.loads(sys.stdin.readline())
try:
desc, anno = task["description"].split(" annotate:")
task["description"] = desc
task["annotations"] = [{"entry": task["entry"], "description": anno}]
except ValueError:
pass
print(json.dumps(task))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment