diff --git a/pit.nimble b/pit.nimble index 05d4b9e..1665157 100644 --- a/pit.nimble +++ b/pit.nimble @@ -1,6 +1,6 @@ # Package -version = "4.9.0" +version = "4.9.1" author = "Jonathan Bernard" description = "Personal issue tracker." license = "MIT" diff --git a/src/pit.nim b/src/pit.nim index 4422b3c..4ed0260 100644 --- a/src/pit.nim +++ b/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 "" + if context.isEmptyOrWhitespace: return "" 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) diff --git a/src/pitpkg/private/libpit.nim b/src/pitpkg/private/libpit.nim index b0f4814..81a7521 100644 --- a/src/pitpkg/private/libpit.nim +++ b/src/pitpkg/private/libpit.nim @@ -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): diff --git a/src/pitpkg/version.nim b/src/pitpkg/version.nim index 235ed62..291b220 100644 --- a/src/pitpkg/version.nim +++ b/src/pitpkg/version.nim @@ -1 +1 @@ -const PIT_VERSION* = "4.9.0" \ No newline at end of file +const PIT_VERSION* = "4.9.1" \ No newline at end of file