Compare commits

...

3 Commits

Author SHA1 Message Date
be7c099b7b Format listed issues plainly when STDOUT is not a TTY 2024-01-01 12:55:01 -06:00
d04797460c Format listed issues plainly when STDIN is not a TTY
When calling pit from other programs or as part of a pipe, the display
style typically used to format listed issues contains a lot of unwanted
output (ANSI escape code, headings, etc.). Now when STDIN is not a TTY,
a plain and consistently formatted version of the issues is listed
without any additional formatting, one issue per line of output.
2024-01-01 12:47:43 -06:00
8cf0bf5d98 Change how time entries based on PIT issues are logged when using --ptk. 2023-12-17 07:32:46 -06:00
3 changed files with 45 additions and 7 deletions

View File

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

View File

@ -70,6 +70,24 @@ proc formatIssue*(issue: Issue): string =
result &= termReset
proc formatPlainIssueSummary*(issue: Issue): string =
result = "$#: $# $#" % [
$issue.state,
($issue.id)[0..<6],
issue.summary ]
if issue.hasProp("delegated-to") or issue.hasProp("pending"):
var parts = newSeq[string]()
if issue.hasProp("delegated-to"):
parts.add("delegated to " & issue["delegated-to"])
if issue.hasProp("pending"):
parts.add("pendin: " & issue["pending"])
result &= "($#)" % [ parts.join("; ") ]
proc formatSectionIssue*(
issue: Issue,
width: int = 80,
@ -251,7 +269,15 @@ proc list(
it.hasProp("completed") and
sameDay(getTime().local, it.getDateTime("completed")))
stdout.write ctx.formatSection(ctx.issues[state], state, "", verbose)
if isatty(stdout):
stdout.write ctx.formatSection(ctx.issues[state], state, "", verbose)
else:
stdout.writeLine ctx.issues[state]
.mapIt(formatPlainIssueSummary(it))
.join("\n")
trace "listing complete"
return
@ -279,7 +305,13 @@ proc list(
not (it.hasProp("hide-until") and
it.getDateTime("hide-until") > getTime().local))
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
if isatty(stdout):
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
else:
stdout.writeLine visibleIssues
.mapIt(formatPlainIssueSummary(it))
.join("\n")
# Future items
if future:
@ -296,7 +328,13 @@ proc list(
not (it.hasProp("hide-until") and
it.getDateTime("hide-until") > getTime().local))
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
if isatty(stdout):
stdout.write ctx.formatSection(visibleIssues, s, indent, verbose)
else:
stdout.writeLine visibleIssues
.mapIt(formatPlainIssueSummary(it))
.join("\n")
trace "listing complete"
@ -463,7 +501,7 @@ when isMainModule:
)
cmd &= " -g \"" & tags.join(",") & "\""
cmd &= " -n \"pit-id: " & $issue.id & "\""
cmd &= " \"" & issue.summary & "\""
cmd &= " \"[" & ($issue.id)[0..<6] & "] " & issue.summary & "\""
discard execShellCmd(cmd)
elif targetState == Done or targetState == Pending:
discard execShellCmd("ptk stop")

View File

@ -1,4 +1,4 @@
const PIT_VERSION* = "4.24.0"
const PIT_VERSION* = "4.25.1"
const USAGE* = """Usage:
pit ( new | add) <summary> [<state>] [options]
@ -185,4 +185,4 @@ Issue Properties:
If present, expected to be a comma-delimited list of text tags. The -g
option is a short-hand for '-p tags:<tags-value>'.
"""
"""