Update to nim 2.2.8, cliutils 0.11.1

This commit is contained in:
2026-03-09 13:30:55 -05:00
parent e35bd9f85a
commit a273091dc7
6 changed files with 67 additions and 65 deletions

View File

@@ -1,2 +1,2 @@
[tools]
nim = "2.2.6"
nim = "2.2.8"

View File

@@ -1,6 +1,6 @@
# Package
version = "4.33.0"
version = "4.33.1"
author = "Jonathan Bernard"
description = "Personal issue tracker."
license = "MIT"
@@ -19,7 +19,7 @@ requires @[
# Dependencies from git.jdb-software.com/jdb/nim-packages
requires @[
"cliutils >= 0.10.2",
"cliutils >= 0.11.1",
"langutils >= 0.4.0",
"timeutils >= 0.5.4",
"data_uri > 1.0.0",

View File

@@ -92,8 +92,8 @@ proc addIssue(
"Do you want to set a value for '" & propName & "'? " &
"You can use the numbers above to use an existing value, enter " &
"something new, or leave blank to indicate no value.\p" &
withColor(propName, fgMagenta) & ":" &
withColor(" ", fgBlue, bright=true, skipReset=true))
color(propName, fg=cMagenta) & ":" &
ansiEscSeq(fg=cBrightBlue) & " ")
let resp = stdin.readLine.strip
let numberResp = resp.match(numberRegex)
@@ -106,7 +106,7 @@ proc addIssue(
elif resp.len > 0:
issueProps[propName] = resp
stdout.writeLine(termReset)
stdout.writeLine(RESET_FORMATTING)
result = Issue(
id: genUUID(),

View File

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

View File

@@ -6,36 +6,36 @@ import ./libpit
proc adjustedTerminalWidth(): int = min(terminalWidth(), 80)
proc formatIssue*(issue: Issue): string =
result = ($issue.id).withColor(fgBlack, true) & "\n"&
issue.summary.withColor(fgWhite) & "\n"
result = ($issue.id).color(cBrightBlack) & "\n"&
issue.summary.color(cWhite) & "\n"
if issue.tags.len > 0:
result &= "tags: ".withColor(fgMagenta) &
issue.tags.join(",").withColor(fgGreen, true) & "\n"
result &= "tags: ".color(cMagenta) &
issue.tags.join(",").color(cBrightGreen) & "\n"
if issue.properties.len > 0:
for k, v in issue.properties:
if k == "project":
result &= "project: ".withColor(fgMagenta) &
v.withColor(fgBlue, bright = true) & "\n"
result &= "project: ".color(cMagenta) &
v.color(cBrightBlue) & "\n"
elif k == "milestone":
result &= "milestone: ".withColor(fgMagenta) &
v.withColor(fgBlue, bright = true) & "\n"
result &= "milestone: ".color(cMagenta) &
v.color(cBrightBlue) & "\n"
elif k == "priority":
result &= "priority: ".withColor(fgMagenta) &
v.withColor(fgRed, bright = true) & "\n"
result &= "priority: ".color(cMagenta) &
v.color(cBrightRed) & "\n"
else:
result &= termColor(fgMagenta) & k & ": " & v & "\n"
result &= ansiEscSeq(fg = cMagenta) & k & ": " & v & "\n"
result &= "--------".withColor(fgBlack, true) & "\n"
result &= "--------".color(cBrightBlack) & "\n"
if not issue.details.isEmptyOrWhitespace:
result &= issue.details.strip.withColor(fgCyan) & "\n"
result &= issue.details.strip.color(cCyan) & "\n"
result &= termReset
result &= RESET_FORMATTING
proc formatPlainIssueSummary*(issue: Issue): string =
@@ -64,7 +64,7 @@ proc formatSectionIssue*(
verbose = false,
bold = false): string =
result = (indent & ($issue.id)[0..<6]).withColor(fgBlack, true) & " "
result = (indent & ($issue.id)[0..<6]).color(cBrightBlack) & " "
let showDetails = not issue.details.isEmptyOrWhitespace and verbose
@@ -75,7 +75,8 @@ proc formatSectionIssue*(
.wrapWords(summaryWidth)
.splitLines
result &= summaryLines[0].termFmt(fgWhite, bold=bold, underline=bold)
result &= summaryLines[0].termFmt(fg=cWhite, bg=cDefault,
style = if bold: { tsBold, tsUnderline } else: {})
for line in summaryLines[1..^1]:
result &= "\p" & line.indent(summaryIndentLen)
@@ -84,11 +85,11 @@ proc formatSectionIssue*(
if issue.hasProp("delegated-to"):
if lastLineLen + issue["delegated-to"].len + 1 < summaryWidth:
result &= " " & issue["delegated-to"].withColor(fgMagenta)
result &= " " & issue["delegated-to"].color(cMagenta)
lastLineLen += issue["delegated-to"].len + 1
else:
result &= "\p" & issue["delegated-to"]
.withColor(fgMagenta)
.color(cMagenta)
.indent(summaryIndentLen)
lastLineLen = issue["delegated-to"].len
@@ -99,28 +100,28 @@ proc formatSectionIssue*(
if tagsStrLines.len == 1 and
(lastLineLen + tagsStrLines[0].len + 1) < summaryWidth:
result &= " " & tagsStrLines[0].withColor(fgGreen)
result &= " " & tagsStrLines[0].color(cGreen)
lastLineLen += tagsStrLines[0].len + 1
else:
result &= "\p" & tagsStrLines
.mapIt(it.indent(summaryIndentLen))
.join("\p")
.withColor(fgGreen)
.color(cGreen)
lastLineLen = tagsStrLines[^1].len
if issue.hasProp("pending"):
result &= "\p" & ("Pending: " & issue["pending"])
.wrapwords(summaryWidth)
.withColor(fgCyan)
.color(cCyan)
.indent(summaryIndentLen)
if showDetails:
result &= "\p" & issue.details
.strip
.withColor(fgBlack, bright = true)
.color(cBrightBlack)
.indent(summaryIndentLen)
result &= termReset
result &= RESET_FORMATTING
proc formatSectionIssueList*(
@@ -139,19 +140,19 @@ proc formatSection(ctx: CliContext, issues: seq[Issue], state: IssueState,
indent = "", verbose = false): string =
let innerWidth = adjustedTerminalWidth() - (indent.len * 2)
result = termColor(fgBlue) &
result = ansiEscSeq(fg = cBlue) &
(indent & ".".repeat(innerWidth)) & "\n" &
state.displayName.center(adjustedTerminalWidth()) & "\n\n" &
termReset
RESET_FORMATTING
let issuesByContext = issues.groupBy("context")
if issues.len > 5 and issuesByContext.len > 1:
for context, ctxIssues in issuesByContext:
result &= termColor(fgYellow) &
result &= ansiEscSeq(fg = cYellow) &
indent & ctx.getIssueContextDisplayName(context) & ":" &
termReset & "\n\n"
RESET_FORMATTING & "\n\n"
result &= formatSectionIssueList(ctxIssues, innerWidth - 2, indent & " ", verbose)
result &= "\n"
@@ -160,11 +161,11 @@ proc formatSection(ctx: CliContext, issues: seq[Issue], state: IssueState,
proc writeHeader*(ctx: CliContext, header: string) =
stdout.setForegroundColor(fgRed, true)
stdout.write(ansiEscSeq(fg = cBrightRed))
stdout.writeLine('_'.repeat(adjustedTerminalWidth()))
stdout.writeLine(header.center(adjustedTerminalWidth()))
stdout.writeLine('~'.repeat(adjustedTerminalWidth()))
stdout.resetAttributes
stdout.write(RESET_FORMATTING)
proc list*(

View File

@@ -152,9 +152,9 @@ proc listProjects*(ctx: CliContext, filter = none[IssueFilter]()) =
for (context, projects) in pairs(projectsByContext):
linesToPrint.add(withColor(
linesToPrint.add(termFmt(
ctx.getIssueContextDisplayName(context) & ":",
fgYellow) & termReset)
fg=cYellow))
linesToPrint.add("")
var toList = toHashSet(toSeq(keys(projects)))
@@ -203,10 +203,10 @@ proc listMilestones*(ctx: CliContext, filter = none[IssueFilter]()) =
if values(project.milestones) --> all(it.len == 0):
continue
linesToPrint.add(withColor(project.name, fgBlue, bold = true, bright=true))
linesToPrint.add(withColor(
linesToPrint.add(termFmt(project.name, cBrightBlue, style = { tsBold }))
linesToPrint.add(termFmt(
"".repeat(runeLen(stripAnsi(project.name))),
fgBlue, bold = true))
cBrightBlue, style = { tsBold} ))
for milestone in project.milestoneOrder:
if project.milestones.hasKey(milestone) and
@@ -229,31 +229,31 @@ proc formatProjectIssue(
var firstLine = ""
if issue.state == IssueState.Done:
firstLine &= withColor("", fgBlack, bold=true, bright=true)
firstLine &= termFmt("", fg = cBrightBlack, style = { tsBold })
else:
case issue.getPriority
of IssuePriority.essential:
firstLine &= withColor("", fgRed, bold=true, bright=true)
firstLine &= termFmt("", fg=cBrightRed, style={ tsBold })
of IssuePriority.vital:
firstLine &= withColor("", fgYellow, bold=true, bright=true)
firstLine &= termFmt("", fg=cBrightYellow, style={ tsBold })
of IssuePriority.important:
firstLine &= withColor("", fgBlue, bold=true, bright=true)
firstLine &= termFmt("", fg=cBrightBlue, style={ tsBold })
of IssuePriority.optional:
firstLine &= withColor("", fgBlack, bold=false, bright=true)
firstLine &= termFmt("", fg=cBrightBlack)
let summaryText = formatSectionIssue(issue, width - 3,
bold = [Current, TodoToday].contains(issue.state)).splitLines
firstLine &= summaryText[0]
if issue.state == IssueState.Done:
firstLine = withColor(stripAnsi(firstLine), fgBlack, bright=true)
firstLine = termFmt(stripAnsi(firstLine), fg=cBrightBlack)
result.add(firstLine)
result.add(summaryText[1 .. ^1] --> map(" " & it))
if issue.state == IssueState.Done:
let origLines = result
result = origLines --> map(withColor(stripAnsi(it), fgBlack, bright=true))
result = origLines --> map(termFmt(stripAnsi(it), fg = cBrightBlack))
proc formatParentIssue*(
ctx: CliContext,
@@ -265,7 +265,7 @@ proc formatParentIssue*(
for child in sorted(children, cmp):
let childLines = ctx.formatProjectIssue(child, width - 3)
result.add(childLines --> map(withColor("", fgBlack, bright=true) & it))
result.add(childLines --> map(termFmt("", fg=cBrightBlack) & it))
result.add("")
@@ -277,8 +277,8 @@ proc formatMilestone*(
availWidth: int): seq[string] =
result = @[""]
result.add(withColor(milestone, fgWhite, bold=true))
result.add(withColor("".repeat(availWidth), fgWhite))
result.add(termFmt(milestone, fg=cWhite, style={tsBold}))
result.add(termFmt("".repeat(availWidth), fg=cWhite))
var parentsToChildren = issues -->
filter(it.hasProp("parent")).group(it["parent"])
@@ -327,18 +327,19 @@ proc showProject*(ctx: CliContext, project: Project) =
let numColumns = (fullWidth - 4) div (columnWidth + 2)
linesToPrint.add("")
linesToPrint.add(withColor(
linesToPrint.add(termFmt(
"" & "".repeat(project.name.runeLen + 2) &
"" & "".repeat(fullWidth - project.name.runeLen - 4) & "",
fgBlue, bold=true))
fg=cBlue, style={tsBold}))
linesToPrint.add(
withColor("", fgBlue, bold=true) &
withColor(project.name, fgBlue, bold=true, bright=true) &
withColor("" & " ".repeat(fullWidth - project.name.runeLen - 4) & "", fgBlue, bold=true))
linesToPrint.add(withColor(
termFmt("", fg=cBlue, style={tsBold}) &
termFmt(project.name, fg=cBrightBlue, style={tsBold}) &
termFmt("" & " ".repeat(fullWidth - project.name.runeLen - 4) & "",
fg=cBlue, style={tsBold}))
linesToPrint.add(termFmt(
"" & "".repeat(project.name.runeLen + 2) &
"" & " ".repeat(fullWidth - project.name.runeLen - 4) & "",
fgBlue, bold=true))
fg=cBlue, style={tsBold}))
let milestoneTexts: seq[seq[string]] = project.milestoneOrder -->
filter(project.milestones.hasKey(it) and project.milestones[it].len > 0).
@@ -355,14 +356,14 @@ proc showProject*(ctx: CliContext, project: Project) =
for line in joinedLines:
let padLen = fullWidth - runeLen(stripAnsi(line)) - 3
linesToPrint.add(
withColor("", fgBlue) &
termFmt("", fg=cBlue) &
line &
" ".repeat(padLen) &
withColor("", fgBlue))
termFmt("", fg=cBlue))
linesToPrint.add(withColor(
linesToPrint.add(termFmt(
"" & "".repeat(terminalWidth() - 2) & "",
fgBlue, bold=true))
fg=cBlue, style={tsBold}))
if isatty(stdout):
stdout.writeLine(linesToPrint.join("\p"))
@@ -389,9 +390,9 @@ proc showProjectBoard*(ctx: CliContext, filter = none[IssueFilter]()) =
for (context, projects) in contextsAndProjects:
if contextsAndProjects.len > 1:
stdout.writeLine("")
stdout.writeLine(withColor(
stdout.writeLine(termFmt(
ctx.getIssueContextDisplayName(context) & ":",
fgYellow, bold=true))
fg=cYellow, style={tsBold}))
stdout.writeLine("")
for p in projects: