due/hw: Make add() take a tag for the due/t tag

This commit is contained in:
Adam Goldsmith 2018-03-12 11:35:32 -04:00
parent 2105f48ebb
commit 556212827a
2 changed files with 6 additions and 5 deletions

5
due.py
View File

@ -46,11 +46,12 @@ class todo_item:
return fancy_text
def add(date_input, desc):
def add(tag, date_input, desc):
print(tag, date_input, desc)
cal = parsedatetime.Calendar()
time_struct, parse_status = cal.parse(date_input)
date = datetime(*time_struct[:6]).strftime("%Y-%m-%d")
subprocess.call(["todo.sh", "add", desc, "t:" + date])
subprocess.call(["todo.sh", "add", desc, tag + ":" + date])
def due(search_term="", relative=False):
command = ["todo.sh", "list"]

6
hw
View File

@ -5,6 +5,7 @@ import sys
import due
PRIORITY = "(B)"
TAG = "due"
if len(sys.argv) < 2:
print("Not enough args!")
@ -32,10 +33,9 @@ elif sys.argv[2] == "add":
c = input("Class")
date = input("Date")
desc = input("Assignment")
due.add(date, "{} +hw class:{} {}".format(PRIORITY, c, desc))
due.add(TAG, date, "{} +hw class:{} {}".format(PRIORITY, c, desc))
elif len(sys.argv) >= 6:
print(sys.argv[3:])
due.add(sys.argv[3],
due.add(TAG, sys.argv[3],
"{} +hw class:{} {}".format(PRIORITY,
sys.argv[4],
" ".join(sys.argv[5:])))