Project boards: only show contexts with selected issues.

This commit is contained in:
2025-11-19 19:00:01 -06:00
parent 5dd7a15bf4
commit 68bfecd9d5
3 changed files with 19 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
# Package # Package
version = "4.30.0" version = "4.30.1"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Personal issue tracker." description = "Personal issue tracker."
license = "MIT" license = "MIT"
@@ -27,4 +27,4 @@ requires @[
] ]
task updateVersion, "Update the version of this package.": task updateVersion, "Update the version of this package.":
exec "update_nim_package_version pit 'src/pit/cliconstants.nim'" exec "update_nim_package_version pit 'src/pit/cliconstants.nim'"

View File

@@ -1,4 +1,4 @@
const PIT_VERSION* = "4.30.0" const PIT_VERSION* = "4.30.1"
const USAGE* = """Usage: const USAGE* = """Usage:
pit ( new | add) <summary> [<state>] [options] pit ( new | add) <summary> [<state>] [options]
@@ -235,4 +235,4 @@ Issue Properties:
If present, expected to be a comma-delimited list of text tags. The -g If present, expected to be a comma-delimited list of text tags. The -g
option is a short-hand for '-p tags:<tags-value>'. option is a short-hand for '-p tags:<tags-value>'.
""" """

View File

@@ -1,5 +1,5 @@
import std/[algorithm, json, jsonutils, options, os, sets, strutils, tables, terminal, import std/[algorithm, json, jsonutils, options, os, sets, strutils, tables,
times, unicode, wordwrap] terminal, times, unicode, wordwrap]
from std/sequtils import repeat, toSeq from std/sequtils import repeat, toSeq
import cliutils, uuids, zero_functional import cliutils, uuids, zero_functional
import ./[formatting, libpit] import ./[formatting, libpit]
@@ -256,8 +256,7 @@ proc formatMilestone*(
result.add(withColor("".repeat(availWidth), fgWhite)) result.add(withColor("".repeat(availWidth), fgWhite))
var parentsToChildren = issues --> var parentsToChildren = issues -->
filter(it.hasProp("parent")) --> filter(it.hasProp("parent")).group(it["parent"])
group(it["parent"])
var issuesToFormat = sorted(issues, cmp) --> var issuesToFormat = sorted(issues, cmp) -->
filter(not it.hasProp("parent")) filter(not it.hasProp("parent"))
@@ -282,7 +281,7 @@ proc findShortestColumn(columns: seq[seq[string]]): int =
proc joinColumns(columns: seq[seq[string]], columnWidth: int): seq[string] = proc joinColumns(columns: seq[seq[string]], columnWidth: int): seq[string] =
let maxLines = columns --> map(it.len) --> max() let maxLines = columns --> map(it.len).max()
for lineNo in 0 ..< maxLines: for lineNo in 0 ..< maxLines:
var newLine = "" var newLine = ""
@@ -316,7 +315,7 @@ proc showProject*(ctx: CliContext, project: Project) =
fgBlue, bold=true)) fgBlue, bold=true))
let milestoneTexts: seq[seq[string]] = project.milestoneOrder --> let milestoneTexts: seq[seq[string]] = project.milestoneOrder -->
filter(project.milestones.hasKey(it) and project.milestones[it].len > 0) --> filter(project.milestones.hasKey(it) and project.milestones[it].len > 0).
map(ctx.formatMilestone(it, project.milestones[it], columnWidth)) map(ctx.formatMilestone(it, project.milestones[it], columnWidth))
var columns: seq[seq[string]] = repeat(newSeq[string](), numColumns) var columns: seq[seq[string]] = repeat(newSeq[string](), numColumns)
@@ -347,8 +346,16 @@ proc showProjectBoard*(ctx: CliContext, filter = none[IssueFilter]()) =
let projectsCfg = ctx.loadProjectsConfiguration() let projectsCfg = ctx.loadProjectsConfiguration()
let projectsDb = ctx.buildDb(projectsCfg) let projectsDb = ctx.buildDb(projectsCfg)
for (context, projects) in pairs(projectsDb): var contextsAndProjects: seq[(string, seq[Project])] = @[]
if projectsDb.len > 1:
for (context, pjs) in pairs(projectsDb):
let projects = pjs
let issues: seq[Issue] = projects --> map(toSeq(values(it.milestones))).flatten().flatten()
if issues.len > 0:
contextsAndProjects.add((context, projects))
for (context, projects) in contextsAndProjects:
if contextsAndProjects.len > 1:
stdout.writeLine("") stdout.writeLine("")
stdout.writeLine(withColor( stdout.writeLine(withColor(
ctx.getIssueContextDisplayName(context) & ":", ctx.getIssueContextDisplayName(context) & ":",