Update to reflect changes in Nim stdlib in v1.2.
This commit is contained in:
parent
339e88cddd
commit
08b9df2086
@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "4.9.0"
|
||||
version = "4.9.1"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Personal issue tracker."
|
||||
license = "MIT"
|
||||
|
12
src/pit.nim
12
src/pit.nim
@ -2,7 +2,7 @@
|
||||
## ====================================
|
||||
|
||||
import cliutils, docopt, json, logging, options, os, sequtils,
|
||||
tables, terminal, times, timeutils, unicode, uuids
|
||||
std/wordwrap, tables, terminal, times, timeutils, unicode, uuids
|
||||
|
||||
from nre import re
|
||||
import strutils except alignLeft, capitalize, strip, toUpper, toLower
|
||||
@ -49,7 +49,7 @@ proc initContext(args: Table[string, Value]): CliContext =
|
||||
|
||||
proc getIssueContextDisplayName(ctx: CliContext, context: string): string =
|
||||
if not ctx.contexts.hasKey(context):
|
||||
if context.isNilOrWhitespace: return "<default>"
|
||||
if context.isEmptyOrWhitespace: return "<default>"
|
||||
else: return context.capitalize()
|
||||
return ctx.contexts[context]
|
||||
|
||||
@ -67,7 +67,7 @@ proc formatIssue(ctx: CliContext, issue: Issue): string =
|
||||
|
||||
|
||||
result &= "--------".withColor(fgBlack, true) & "\n"
|
||||
if not issue.details.isNilOrWhitespace:
|
||||
if not issue.details.isEmptyOrWhitespace:
|
||||
result &= issue.details.strip.withColor(fgCyan) & "\n"
|
||||
|
||||
proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
||||
@ -75,7 +75,7 @@ proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
||||
|
||||
result = ""
|
||||
|
||||
var showDetails = not issue.details.isNilOrWhitespace and verbose
|
||||
var showDetails = not issue.details.isEmptyOrWhitespace and verbose
|
||||
|
||||
var prefixLen = 0
|
||||
var summaryIndentLen = indent.len + 7
|
||||
@ -83,7 +83,7 @@ proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
||||
if issue.hasProp("delegated-to"): prefixLen += issue["delegated-to"].len + 2 # space for the ':' and ' '
|
||||
|
||||
# Wrap and write the summary.
|
||||
var wrappedSummary = ("+".repeat(prefixLen) & issue.summary).wordWrap(width - summaryIndentLen).indent(summaryIndentLen)
|
||||
var wrappedSummary = ("+".repeat(prefixLen) & issue.summary).wrapWords(width - summaryIndentLen).indent(summaryIndentLen)
|
||||
|
||||
wrappedSummary = wrappedSummary[(prefixLen + summaryIndentLen)..^1]
|
||||
|
||||
@ -103,7 +103,7 @@ proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
||||
|
||||
if issue.hasProp("pending"):
|
||||
let startIdx = "Pending: ".len
|
||||
var pendingText = issue["pending"].wordWrap(width - startIdx - summaryIndentLen)
|
||||
var pendingText = issue["pending"].wrapWords(width - startIdx - summaryIndentLen)
|
||||
.indent(startIdx)
|
||||
pendingText = ("Pending: " & pendingText[startIdx..^1]).indent(summaryIndentLen)
|
||||
result &= "\n" & pendingText.withColor(fgCyan)
|
||||
|
@ -122,7 +122,7 @@ proc fromStorageFormat*(id: string, issueTxt: string): Issue =
|
||||
|
||||
of ReadingProps:
|
||||
# Ignore empty lines
|
||||
if line.isNilOrWhitespace: continue
|
||||
if line.isEmptyOrWhitespace: continue
|
||||
|
||||
# Look for the sentinal to start parsing as detail lines
|
||||
if line == "--------":
|
||||
@ -149,9 +149,9 @@ proc toStorageFormat*(issue: Issue, withComments = false): string =
|
||||
lines.add(issue.summary)
|
||||
if withComments: lines.add("# Properties (\"key:value\" per line):")
|
||||
for key, val in issue.properties:
|
||||
if not val.isNilOrWhitespace: lines.add(key & ": " & val)
|
||||
if not val.isEmptyOrWhitespace: lines.add(key & ": " & val)
|
||||
if issue.tags.len > 0: lines.add("tags: " & issue.tags.join(","))
|
||||
if not isNilOrWhitespace(issue.details) or withComments:
|
||||
if not isEmptyOrWhitespace(issue.details) or withComments:
|
||||
if withComments: lines.add("# Details go below the \"--------\"")
|
||||
lines.add("--------")
|
||||
lines.add(issue.details)
|
||||
@ -202,7 +202,7 @@ proc loadIssues*(path: string): seq[Issue] =
|
||||
toSeq(orderFile.lines)
|
||||
.mapIt(it.split(' ')[0])
|
||||
.deduplicate
|
||||
.filterIt(not it.startsWith("> ") and not it.isNilOrWhitespace)
|
||||
.filterIt(not it.startsWith("> ") and not it.isEmptyOrWhitespace)
|
||||
else: newSeq[string]()
|
||||
|
||||
type TaggedIssue = tuple[issue: Issue, ordered: bool]
|
||||
@ -269,7 +269,7 @@ proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitCo
|
||||
|
||||
if not existsFile(pitrcFilename):
|
||||
warn "pit: could not find .pitrc file: " & pitrcFilename
|
||||
if isNilOrWhitespace(pitrcFilename):
|
||||
if isEmptyOrWhitespace(pitrcFilename):
|
||||
pitrcFilename = $getEnv("HOME") & "/.pitrc"
|
||||
var cfgFile: File
|
||||
try:
|
||||
@ -295,7 +295,7 @@ proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitCo
|
||||
for k, v in cfgJson["contexts"]:
|
||||
result.contexts[k] = v.getStr()
|
||||
|
||||
if isNilOrWhitespace(result.tasksDir):
|
||||
if isEmptyOrWhitespace(result.tasksDir):
|
||||
raise newException(Exception, "no tasks directory configured")
|
||||
|
||||
if not existsDir(result.tasksDir):
|
||||
|
@ -1 +1 @@
|
||||
const PIT_VERSION* = "4.9.0"
|
||||
const PIT_VERSION* = "4.9.1"
|
Loading…
x
Reference in New Issue
Block a user