Compare commits

...

2 Commits

6 changed files with 36 additions and 11 deletions

View File

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

View File

@ -200,17 +200,26 @@ proc edit(issue: Issue) =
getCurrentExceptionMsg() getCurrentExceptionMsg()
issue.store() issue.store()
proc list(ctx: CliContext, filter: Option[IssueFilter], states: Option[seq[IssueState]], showToday, showFuture, verbose: bool) = proc list(
ctx: CliContext,
filter: Option[IssueFilter],
states: Option[seq[IssueState]],
showToday, showFuture,
showHidden = false,
verbose: bool) =
if states.isSome: if states.isSome:
trace "listing issues for " & $states.get trace "listing issues for " & $states.get
for state in states.get: for state in states.get:
ctx.loadIssues(state) ctx.loadIssues(state)
if filter.isSome: ctx.filterIssues(filter.get) if filter.isSome: ctx.filterIssues(filter.get)
# Show Done for just today if requested
if state == Done and showToday: if state == Done and showToday:
ctx.issues[Done] = ctx.issues[Done].filterIt( ctx.issues[Done] = ctx.issues[Done].filterIt(
it.hasProp("completed") and it.hasProp("completed") and
sameDay(getTime().local, it.getDateTime("completed"))) sameDay(getTime().local, it.getDateTime("completed")))
stdout.write ctx.formatSection(ctx.issues[state], state, "", verbose) stdout.write ctx.formatSection(ctx.issues[state], state, "", verbose)
trace "listing complete" trace "listing complete"
return return
@ -234,7 +243,12 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], states: Option[seq[Issue
for s in [Current, TodoToday, Pending]: for s in [Current, TodoToday, Pending]:
if ctx.issues.hasKey(s) and ctx.issues[s].len > 0: 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(
showHidden or
not (it.hasProp("hide-until") and
it.getDateTime("hide-until") > getTime().local))
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
# Future items # Future items
if future: if future:
@ -243,6 +257,7 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], states: Option[seq[Issue
for s in [Pending, Todo]: for s in [Pending, Todo]:
if ctx.issues.hasKey(s) and ctx.issues[s].len > 0: if ctx.issues.hasKey(s) and ctx.issues[s].len > 0:
let visibleIssues = ctx.issues[s].filterIt( let visibleIssues = ctx.issues[s].filterIt(
showHidden or
not (it.hasProp("hide-until") and not (it.hasProp("hide-until") and
it.getDateTime("hide-until") > getTime().local)) it.getDateTime("hide-until") > getTime().local))
@ -378,6 +393,9 @@ when isMainModule:
if issue.hasProp("recurrence") and issue.getRecurrence.isSome: if issue.hasProp("recurrence") and issue.getRecurrence.isSome:
let nextIssue = ctx.tasksDir.nextRecurrence(issue.getRecurrence.get, issue) let nextIssue = ctx.tasksDir.nextRecurrence(issue.getRecurrence.get, issue)
ctx.tasksDir.store(nextIssue, Todo) ctx.tasksDir.store(nextIssue, Todo)
info "created the next recurrence:"
stdout.writeLine ctx.formatIssue(nextIssue)
issue.changeState(ctx.tasksDir, targetState) issue.changeState(ctx.tasksDir, targetState)
@ -495,9 +513,13 @@ when isMainModule:
else: else:
trace "listing all issues" trace "listing all issues"
let showBoth = args["--today"] == args["--future"] let showBoth = args["--today"] == args["--future"]
ctx.list(filterOption, statesOption, showBoth or args["--today"], ctx.list(
showBoth or args["--future"], filter = filterOption,
ctx.verbose) states = statesOption,
showToday = showBoth or args["--today"],
showFuture = showBoth or args["--future"],
showHidden = args["--show-hidden"],
verbose = ctx.verbose)
elif args["add-binary-property"]: elif args["add-binary-property"]:
let issue = ctx.tasksDir.loadIssueById($(args["<id>"])) let issue = ctx.tasksDir.loadIssueById($(args["<id>"]))

View File

@ -40,10 +40,10 @@ template checkAuth(cfg: PitApiCfg) =
var authed {.inject.} = false var authed {.inject.} = false
try: try:
if not request.headers.hasKey("Authorization"): if not headers(request).hasKey("Authorization"):
raiseEx "No auth token." raiseEx "No auth token."
let headerVal = request.headers["Authorization"] let headerVal = headers(request)["Authorization"]
if not headerVal.startsWith("Bearer "): if not headerVal.startsWith("Bearer "):
raiseEx "Invalid Authentication type (only 'Bearer' is supported)." raiseEx "Invalid Authentication type (only 'Bearer' is supported)."

View File

@ -315,8 +315,8 @@ proc nextRecurrence*(tasksDir: string, rec: Recurrence, defaultIssue: Issue): Is
let newProps = newTable[string,string]() let newProps = newTable[string,string]()
for k, v in baseIssue.properties: for k, v in baseIssue.properties:
if k != "created" and k != "completed": if k != "completed": newProps[k] = v
newProps[k] = v newProps["prev-recurrence"] = $baseIssue.id
result = Issue( result = Issue(
id: genUUID(), id: genUUID(),

View File

@ -1 +1 @@
const PIT_VERSION* = "4.16.0" const PIT_VERSION* = "4.18.0"

View File

@ -31,6 +31,9 @@ Options:
-F, --future Limit to future issues. -F, --future Limit to future issues.
-H, --show-hidden Show all matching issues, ignoring any 'hide-until'
properties set.
-m, --match <pattern> Limit to issues whose summaries match the given -m, --match <pattern> Limit to issues whose summaries match the given
pattern (PCRE regex supported). pattern (PCRE regex supported).