Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9606e71cec | |||
98f4dda1ad | |||
393be347c9 |
11
pit.nimble
11
pit.nimble
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "4.10.0"
|
version = "4.12.0"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal issue tracker."
|
description = "Personal issue tracker."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@ -15,10 +15,11 @@ requires @[
|
|||||||
"jester 0.5.0",
|
"jester 0.5.0",
|
||||||
"uuids 0.1.10",
|
"uuids 0.1.10",
|
||||||
|
|
||||||
"https://git.jdb-labs.com/jdb/nim-cli-utils.git >= 0.6.4",
|
"https://git.jdb-software.com/jdb/nim-cli-utils.git >= 0.6.4",
|
||||||
"https://git.jdb-labs.com/jdb/nim-lang-utils.git >= 0.4.0",
|
"https://git.jdb-software.com/jdb/nim-lang-utils.git >= 0.4.0",
|
||||||
"https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.4.0",
|
"https://git.jdb-software.com/jdb/nim-time-utils.git >= 0.4.0",
|
||||||
"https://git.jdb-labs.com/jdb/update-nim-package-version"
|
"https://git.jdb-software.com/jdb/nim-data-uri.git >= 1.0.0",
|
||||||
|
"https://git.jdb-software.com/jdb/update-nim-package-version"
|
||||||
]
|
]
|
||||||
|
|
||||||
task updateVersion, "Update the version of this package.":
|
task updateVersion, "Update the version of this package.":
|
||||||
|
46
src/pit.nim
46
src/pit.nim
@ -1,8 +1,8 @@
|
|||||||
## Personal Issue Tracker CLI interface
|
## Personal Issue Tracker CLI interface
|
||||||
## ====================================
|
## ====================================
|
||||||
|
|
||||||
import algorithm, cliutils, docopt, json, logging, options, os, sequtils,
|
import algorithm, cliutils, data_uri, docopt, json, logging, options, os,
|
||||||
std/wordwrap, tables, terminal, times, timeutils, unicode, uuids
|
sequtils, 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
|
||||||
@ -70,6 +70,8 @@ proc formatIssue(ctx: CliContext, issue: Issue): string =
|
|||||||
if not issue.details.isEmptyOrWhitespace:
|
if not issue.details.isEmptyOrWhitespace:
|
||||||
result &= issue.details.strip.withColor(fgCyan) & "\n"
|
result &= issue.details.strip.withColor(fgCyan) & "\n"
|
||||||
|
|
||||||
|
result &= termReset
|
||||||
|
|
||||||
proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
proc formatSectionIssue(ctx: CliContext, issue: Issue, width: int, indent = "",
|
||||||
verbose = false): string =
|
verbose = false): string =
|
||||||
|
|
||||||
@ -199,6 +201,10 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], state: Option[IssueState
|
|||||||
if state.isSome:
|
if state.isSome:
|
||||||
ctx.loadIssues(state.get)
|
ctx.loadIssues(state.get)
|
||||||
if filter.isSome: ctx.filterIssues(filter.get)
|
if filter.isSome: ctx.filterIssues(filter.get)
|
||||||
|
if state.get == Done and showToday:
|
||||||
|
ctx.issues[Done] = ctx.issues[Done].filterIt(
|
||||||
|
it.hasProp("completed") and
|
||||||
|
sameDay(getTime().local, it.getDateTime("completed")))
|
||||||
stdout.write ctx.formatSection(ctx.issues[state.get], state.get, "", verbose)
|
stdout.write ctx.formatSection(ctx.issues[state.get], state.get, "", verbose)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -221,13 +227,6 @@ proc list(ctx: CliContext, filter: Option[IssueFilter], state: Option[IssueState
|
|||||||
if ctx.issues.hasKey(s) and ctx.issues[s].len > 0:
|
if ctx.issues.hasKey(s) and ctx.issues[s].len > 0:
|
||||||
stdout.write ctx.formatSection(ctx.issues[s], s, indent, verbose)
|
stdout.write ctx.formatSection(ctx.issues[s], s, indent, verbose)
|
||||||
|
|
||||||
if ctx.issues.hasKey(Done):
|
|
||||||
let doneIssues = ctx.issues[Done].filterIt(
|
|
||||||
it.hasProp("completed") and
|
|
||||||
sameDay(getTime().local, it.getDateTime("completed")))
|
|
||||||
if doneIssues.len > 0:
|
|
||||||
stdout.write ctx.formatSection(doneIssues, Done, indent, verbose)
|
|
||||||
|
|
||||||
# Future items
|
# Future items
|
||||||
if future:
|
if future:
|
||||||
if today: ctx.writeHeader("Future")
|
if today: ctx.writeHeader("Future")
|
||||||
@ -251,6 +250,8 @@ Usage:
|
|||||||
pit reorder <state>
|
pit reorder <state>
|
||||||
pit delegate <id> <delegated-to>
|
pit delegate <id> <delegated-to>
|
||||||
pit ( delete | rm ) <id>...
|
pit ( delete | rm ) <id>...
|
||||||
|
pit add-binary-property <id> <propName> <propSource>
|
||||||
|
pit get-binary-property <id> <propName> <propDest>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
@ -514,6 +515,33 @@ Options:
|
|||||||
showBoth or args["--future"],
|
showBoth or args["--future"],
|
||||||
ctx.verbose)
|
ctx.verbose)
|
||||||
|
|
||||||
|
elif args["add-binary-property"]:
|
||||||
|
let issue = ctx.tasksDir.loadIssueById($(args["<id>"]))
|
||||||
|
|
||||||
|
let propIn =
|
||||||
|
if $(args["<propSource>"]) == "-": stdin
|
||||||
|
else: open($(args["<propSource>"]))
|
||||||
|
|
||||||
|
try: issue[$(args["<propName>"])] = encodeAsDataUri(readAll(propIn))
|
||||||
|
finally: close(propIn)
|
||||||
|
|
||||||
|
issue.store()
|
||||||
|
|
||||||
|
elif args["get-binary-property"]:
|
||||||
|
let issue = ctx.tasksDir.loadIssueById($(args["<id>"]))
|
||||||
|
|
||||||
|
if not issue.hasProp($(args["<propName>"])):
|
||||||
|
raise newException(Exception,
|
||||||
|
"issue " & ($issue.id)[0..<6] & " has no property name '" &
|
||||||
|
$(args["<propName>"]) & "'")
|
||||||
|
|
||||||
|
let propOut =
|
||||||
|
if $(args["<propDest>"]) == "-": stdout
|
||||||
|
else: open($(args["<propDest>"]), fmWrite)
|
||||||
|
|
||||||
|
try: write(propOut, decodeDataUri(issue[$(args["<propName>"])]))
|
||||||
|
finally: close(propOut)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
fatal "pit: " & getCurrentExceptionMsg()
|
fatal "pit: " & getCurrentExceptionMsg()
|
||||||
#raise getCurrentException()
|
#raise getCurrentException()
|
||||||
|
@ -20,7 +20,7 @@ proc raiseEx(reason: string): void = raise newException(Exception, reason)
|
|||||||
|
|
||||||
template halt(code: HttpCode,
|
template halt(code: HttpCode,
|
||||||
headers: RawHeaders,
|
headers: RawHeaders,
|
||||||
content: string): typed =
|
content: string): void =
|
||||||
## Immediately replies with the specified request. This means any further
|
## Immediately replies with the specified request. This means any further
|
||||||
## code will not be executed after calling this template in the current
|
## code will not be executed after calling this template in the current
|
||||||
## route.
|
## route.
|
||||||
|
@ -1 +1 @@
|
|||||||
const PIT_VERSION* = "4.10.0"
|
const PIT_VERSION* = "4.12.0"
|
Reference in New Issue
Block a user