Update to reflect changes in Nim stdlib in v1.2.

This commit is contained in:
Jonathan Bernard 2020-07-06 11:39:57 -05:00
parent 339e88cddd
commit 08b9df2086
4 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# Package # Package
version = "4.9.0" version = "4.9.1"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Personal issue tracker." description = "Personal issue tracker."
license = "MIT" license = "MIT"

View File

@ -2,7 +2,7 @@
## ==================================== ## ====================================
import cliutils, docopt, json, logging, options, os, sequtils, 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 from nre import re
import strutils except alignLeft, capitalize, strip, toUpper, toLower 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 = proc getIssueContextDisplayName(ctx: CliContext, context: string): string =
if not ctx.contexts.hasKey(context): if not ctx.contexts.hasKey(context):
if context.isNilOrWhitespace: return "<default>" if context.isEmptyOrWhitespace: return "<default>"
else: return context.capitalize() else: return context.capitalize()
return ctx.contexts[context] return ctx.contexts[context]
@ -67,7 +67,7 @@ proc formatIssue(ctx: CliContext, issue: Issue): string =
result &= "--------".withColor(fgBlack, true) & "\n" result &= "--------".withColor(fgBlack, true) & "\n"
if not issue.details.isNilOrWhitespace: if not issue.details.isEmptyOrWhitespace:
result &= issue.details.strip.withColor(fgCyan) & "\n" result &= issue.details.strip.withColor(fgCyan) & "\n"
proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "", proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
@ -75,7 +75,7 @@ proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
result = "" result = ""
var showDetails = not issue.details.isNilOrWhitespace and verbose var showDetails = not issue.details.isEmptyOrWhitespace and verbose
var prefixLen = 0 var prefixLen = 0
var summaryIndentLen = indent.len + 7 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 ' ' if issue.hasProp("delegated-to"): prefixLen += issue["delegated-to"].len + 2 # space for the ':' and ' '
# Wrap and write the summary. # 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] wrappedSummary = wrappedSummary[(prefixLen + summaryIndentLen)..^1]
@ -103,7 +103,7 @@ proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
if issue.hasProp("pending"): if issue.hasProp("pending"):
let startIdx = "Pending: ".len let startIdx = "Pending: ".len
var pendingText = issue["pending"].wordWrap(width - startIdx - summaryIndentLen) var pendingText = issue["pending"].wrapWords(width - startIdx - summaryIndentLen)
.indent(startIdx) .indent(startIdx)
pendingText = ("Pending: " & pendingText[startIdx..^1]).indent(summaryIndentLen) pendingText = ("Pending: " & pendingText[startIdx..^1]).indent(summaryIndentLen)
result &= "\n" & pendingText.withColor(fgCyan) result &= "\n" & pendingText.withColor(fgCyan)

View File

@ -122,7 +122,7 @@ proc fromStorageFormat*(id: string, issueTxt: string): Issue =
of ReadingProps: of ReadingProps:
# Ignore empty lines # Ignore empty lines
if line.isNilOrWhitespace: continue if line.isEmptyOrWhitespace: continue
# Look for the sentinal to start parsing as detail lines # Look for the sentinal to start parsing as detail lines
if line == "--------": if line == "--------":
@ -149,9 +149,9 @@ proc toStorageFormat*(issue: Issue, withComments = false): string =
lines.add(issue.summary) lines.add(issue.summary)
if withComments: lines.add("# Properties (\"key:value\" per line):") if withComments: lines.add("# Properties (\"key:value\" per line):")
for key, val in issue.properties: 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 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 \"--------\"") if withComments: lines.add("# Details go below the \"--------\"")
lines.add("--------") lines.add("--------")
lines.add(issue.details) lines.add(issue.details)
@ -202,7 +202,7 @@ proc loadIssues*(path: string): seq[Issue] =
toSeq(orderFile.lines) toSeq(orderFile.lines)
.mapIt(it.split(' ')[0]) .mapIt(it.split(' ')[0])
.deduplicate .deduplicate
.filterIt(not it.startsWith("> ") and not it.isNilOrWhitespace) .filterIt(not it.startsWith("> ") and not it.isEmptyOrWhitespace)
else: newSeq[string]() else: newSeq[string]()
type TaggedIssue = tuple[issue: Issue, ordered: bool] 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): if not existsFile(pitrcFilename):
warn "pit: could not find .pitrc file: " & pitrcFilename warn "pit: could not find .pitrc file: " & pitrcFilename
if isNilOrWhitespace(pitrcFilename): if isEmptyOrWhitespace(pitrcFilename):
pitrcFilename = $getEnv("HOME") & "/.pitrc" pitrcFilename = $getEnv("HOME") & "/.pitrc"
var cfgFile: File var cfgFile: File
try: try:
@ -295,7 +295,7 @@ proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitCo
for k, v in cfgJson["contexts"]: for k, v in cfgJson["contexts"]:
result.contexts[k] = v.getStr() result.contexts[k] = v.getStr()
if isNilOrWhitespace(result.tasksDir): if isEmptyOrWhitespace(result.tasksDir):
raise newException(Exception, "no tasks directory configured") raise newException(Exception, "no tasks directory configured")
if not existsDir(result.tasksDir): if not existsDir(result.tasksDir):

View File

@ -1 +1 @@
const PIT_VERSION* = "4.9.0" const PIT_VERSION* = "4.9.1"