Move issue loading logic into the publicly-exposed library methods.

This commit is contained in:
2023-02-16 11:06:47 -06:00
parent ae4a943e82
commit ea9f8ea7ac
4 changed files with 27 additions and 23 deletions

View File

@ -1,4 +1,4 @@
const PIT_VERSION* = "4.21.2"
const PIT_VERSION* = "4.22.0"
const USAGE* = """Usage:
pit ( new | add) <summary> [<state>] [options]

View File

@ -306,6 +306,13 @@ proc loadIssues*(path: string): seq[Issue] =
# Finally, save current order
result.storeOrder(path)
proc loadIssues*(tasksDir: string, state: IssueState): seq[Issue] =
loadIssues(tasksDir / $state)
proc loadAllIssues*(tasksDir: string): TableRef[IssueState, seq[Issue]] =
result = newTable[IssueState, seq[Issue]]()
for state in IssueState: result[state] = tasksDir.loadIssues(state)
proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
let oldFilepath = issue.filepath
if newState == Done: issue.setDateTime("completed", getTime().local)