Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
08b9df2086 | |||
339e88cddd |
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "4.8.0"
|
version = "4.9.1"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal issue tracker."
|
description = "Personal issue tracker."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
22
src/pit.nim
22
src/pit.nim
@ -2,10 +2,10 @@
|
|||||||
## ====================================
|
## ====================================
|
||||||
|
|
||||||
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 capitalize, strip, toUpper, toLower
|
import strutils except alignLeft, capitalize, strip, toUpper, toLower
|
||||||
import pitpkg/private/libpit
|
import pitpkg/private/libpit
|
||||||
export libpit
|
export libpit
|
||||||
|
|
||||||
@ -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)
|
||||||
@ -490,7 +490,13 @@ Options:
|
|||||||
if issue.hasProp("context") and not uniqContexts.contains(issue["context"]):
|
if issue.hasProp("context") and not uniqContexts.contains(issue["context"]):
|
||||||
uniqContexts.add(issue["context"])
|
uniqContexts.add(issue["context"])
|
||||||
|
|
||||||
for c in uniqContexts: stdout.writeLine(c)
|
let maxLen = foldl(uniqContexts,
|
||||||
|
if a.len > b.len: a
|
||||||
|
else: b
|
||||||
|
).len
|
||||||
|
|
||||||
|
for c in uniqContexts:
|
||||||
|
stdout.writeLine(c.alignLeft(maxLen+2) & ctx.getIssueContextDisplayName(c))
|
||||||
|
|
||||||
# List a specific issue
|
# List a specific issue
|
||||||
elif issueIdOption.isSome:
|
elif issueIdOption.isSome:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import cliutils, docopt, json, logging, langutils, options, os, ospaths,
|
import cliutils, docopt, json, logging, langutils, options, os,
|
||||||
sequtils, strutils, tables, times, timeutils, uuids
|
sequtils, strutils, tables, times, timeutils, uuids
|
||||||
|
|
||||||
from nre import find, match, re, Regex
|
from nre import find, match, re, Regex
|
||||||
@ -49,6 +49,7 @@ proc `[]`*(issue: Issue, key: string): string =
|
|||||||
proc `[]=`*(issue: Issue, key: string, value: string) =
|
proc `[]=`*(issue: Issue, key: string, value: string) =
|
||||||
issue.properties[key] = value
|
issue.properties[key] = value
|
||||||
|
|
||||||
|
## Issue property accessors
|
||||||
proc hasProp*(issue: Issue, key: string): bool =
|
proc hasProp*(issue: Issue, key: string): bool =
|
||||||
return issue.properties.hasKey(key)
|
return issue.properties.hasKey(key)
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ proc getDateTime*(issue: Issue, key: string, default: DateTime): DateTime =
|
|||||||
proc setDateTime*(issue: Issue, key: string, dt: DateTime) =
|
proc setDateTime*(issue: Issue, key: string, dt: DateTime) =
|
||||||
issue.properties[key] = dt.formatIso8601
|
issue.properties[key] = dt.formatIso8601
|
||||||
|
|
||||||
|
## Issue filtering
|
||||||
proc initFilter*(): IssueFilter =
|
proc initFilter*(): IssueFilter =
|
||||||
result = IssueFilter(
|
result = IssueFilter(
|
||||||
completedRange: none(tuple[b, e: DateTime]),
|
completedRange: none(tuple[b, e: DateTime]),
|
||||||
@ -120,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 == "--------":
|
||||||
@ -147,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)
|
||||||
@ -200,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]
|
||||||
@ -267,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:
|
||||||
@ -293,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):
|
||||||
|
@ -1 +1 @@
|
|||||||
const PIT_VERSION* = "4.8.0"
|
const PIT_VERSION* = "4.9.1"
|
Reference in New Issue
Block a user