GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
148 stars 28 forks source link

Add support for task completion percentage? #128

Closed mpenning closed 11 months ago

mpenning commented 11 months ago

Is there an objection to adding a new task attribute called completion_percentage?

The proposal is to make this an integer that would start at 0 and automatically be set to 100 if the task is boolean completed. A task would also be completed if the completion_percentage is set to 100.

I will submit a PR if this functionality is allowed; however, I think that Taskwarrior itself does not support a completion percentage.

mpenning commented 11 months ago

I just realized I could hijack tags functionality to add this myself without changes to tasklib; it's quite hackish, but it can be done as long as you assume that tag consistency is maintained (which is probably more doable than adding xyz custom attribute that I may only use).

import tasklib
tw = tasklib.TaskWarrior()
mytask = tasklib.Task(tw, description="My task with completion", due="2023-12-25")
mytask["tags"] = ["completion!0"]
mytask["tags"].remove("completion!0")
mytask["tags"].add("completion!20")