Add the ability to hide tasks until a certain date.

This commit is contained in:
Jonathan Bernard 2021-08-24 10:56:47 -05:00
parent 9606e71cec
commit d93c0cf348
4 changed files with 38 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "4.12.0"
version = "4.13.0"
author = "Jonathan Bernard"
description = "Personal issue tracker."
license = "MIT"

View File

@ -233,7 +233,11 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], state: Option[IssueState
for s in [Pending, Todo]:
if ctx.issues.hasKey(s) and ctx.issues[s].len > 0:
stdout.write ctx.formatSection(ctx.issues[s], s, indent, verbose)
let visibleIssues = ctx.issues[s].filterIt(
not (it.hasProp("hide-until") and
it.getDateTime("hide-until") > getTime().local))
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
when isMainModule:
@ -241,17 +245,18 @@ when isMainModule:
let doc = """
Usage:
pit ( new | add) <summary> [<state>] [options]
pit list contexts
pit list contexts [options]
pit list [<stateOrId>] [options]
pit ( start | done | pending | todo-today | todo | suspend ) <id>... [options]
pit edit <ref>...
pit edit <ref>... [options]
pit tag <id>... [options]
pit untag <id>... [options]
pit reorder <state>
pit reorder <state> [options]
pit delegate <id> <delegated-to>
pit ( delete | rm ) <id>...
pit add-binary-property <id> <propName> <propSource>
pit get-binary-property <id> <propName> <propDest>
pit hide-until <id> <date> [options]
pit ( delete | rm ) <id>... [options]
pit add-binary-property <id> <propName> <propSource> [options]
pit get-binary-property <id> <propName> <propDest> [options]
Options:
@ -423,6 +428,13 @@ Options:
elif targetState == Done or targetState == Pending:
discard execShellCmd("ptk stop")
elif args["hide-until"]:
let issue = ctx.tasksDir.loadIssueById($(args["<id>"]))
issue.setDateTime("hide-until", parseDate($args["<date>"]))
issue.store()
elif args["delegate"]:
let issue = ctx.tasksDir.loadIssueById($(args["<id>"]))

View File

@ -105,6 +105,23 @@ proc groupBy*(issues: seq[Issue], propertyKey: string): TableRef[string, seq[Iss
result[key].add(i)
## Parse and format dates
const DATE_FORMATS = [
"MM/dd",
"MM-dd",
"yyyy-MM-dd",
"yyyy/MM/dd",
"yyyy-MM-dd'T'hh:mm:ss"
]
proc parseDate*(d: string): DateTime =
var errMsg = ""
for df in DATE_FORMATS:
try: return d.parse(df)
except:
errMsg &= "\n\tTried " & df & " with " & d
continue
raise newException(ValueError, "Unable to parse input as a date: " & d & errMsg)
## Parse and format issues
proc fromStorageFormat*(id: string, issueTxt: string): Issue =
type ParseState = enum ReadingSummary, ReadingProps, ReadingDetails

View File

@ -1 +1 @@
const PIT_VERSION* = "4.12.0"
const PIT_VERSION* = "4.13.0"