Add --show-hidden to ignore hide-until properties.

This commit is contained in:
Jonathan Bernard 2022-01-04 22:27:08 -06:00
parent df854f864c
commit 71e035fdbe
5 changed files with 28 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Package # Package
version = "4.17.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,7 +200,13 @@ 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
@ -237,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:
@ -246,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))
@ -501,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

@ -1 +1 @@
const PIT_VERSION* = "4.17.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).