From 71e035fdbe18ab8d1b6af93881cb4a1c063e7367 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Tue, 4 Jan 2022 22:27:08 -0600 Subject: [PATCH] Add --show-hidden to ignore hide-until properties. --- pit.nimble | 2 +- src/pit.nim | 26 +++++++++++++++++++++----- src/pit_api.nim | 4 ++-- src/pitpkg/version.nim | 2 +- src/usage.txt | 3 +++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pit.nimble b/pit.nimble index 69f7bfb..b5963b4 100644 --- a/pit.nimble +++ b/pit.nimble @@ -1,6 +1,6 @@ # Package -version = "4.17.0" +version = "4.18.0" author = "Jonathan Bernard" description = "Personal issue tracker." license = "MIT" diff --git a/src/pit.nim b/src/pit.nim index 9a3ef08..e5ef608 100644 --- a/src/pit.nim +++ b/src/pit.nim @@ -200,7 +200,13 @@ proc edit(issue: Issue) = getCurrentExceptionMsg() 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: 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]: 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 if future: @@ -246,6 +257,7 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], states: Option[seq[Issue for s in [Pending, Todo]: if ctx.issues.hasKey(s) and ctx.issues[s].len > 0: let visibleIssues = ctx.issues[s].filterIt( + showHidden or not (it.hasProp("hide-until") and it.getDateTime("hide-until") > getTime().local)) @@ -501,9 +513,13 @@ when isMainModule: else: trace "listing all issues" let showBoth = args["--today"] == args["--future"] - ctx.list(filterOption, statesOption, showBoth or args["--today"], - showBoth or args["--future"], - ctx.verbose) + ctx.list( + filter = filterOption, + states = statesOption, + showToday = showBoth or args["--today"], + showFuture = showBoth or args["--future"], + showHidden = args["--show-hidden"], + verbose = ctx.verbose) elif args["add-binary-property"]: let issue = ctx.tasksDir.loadIssueById($(args[""])) diff --git a/src/pit_api.nim b/src/pit_api.nim index 7984b05..4602d37 100644 --- a/src/pit_api.nim +++ b/src/pit_api.nim @@ -40,10 +40,10 @@ template checkAuth(cfg: PitApiCfg) = var authed {.inject.} = false try: - if not request.headers.hasKey("Authorization"): + if not headers(request).hasKey("Authorization"): raiseEx "No auth token." - let headerVal = request.headers["Authorization"] + let headerVal = headers(request)["Authorization"] if not headerVal.startsWith("Bearer "): raiseEx "Invalid Authentication type (only 'Bearer' is supported)." diff --git a/src/pitpkg/version.nim b/src/pitpkg/version.nim index edcf5db..182f223 100644 --- a/src/pitpkg/version.nim +++ b/src/pitpkg/version.nim @@ -1 +1 @@ -const PIT_VERSION* = "4.17.0" \ No newline at end of file +const PIT_VERSION* = "4.18.0" \ No newline at end of file diff --git a/src/usage.txt b/src/usage.txt index 4c1a955..f0dcc71 100644 --- a/src/usage.txt +++ b/src/usage.txt @@ -31,6 +31,9 @@ Options: -F, --future Limit to future issues. + -H, --show-hidden Show all matching issues, ignoring any 'hide-until' + properties set. + -m, --match Limit to issues whose summaries match the given pattern (PCRE regex supported).