Add support for binary properties via data URIs.
This commit is contained in:
parent
98f4dda1ad
commit
9606e71cec
11
pit.nimble
11
pit.nimble
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "4.11.1"
|
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.":
|
||||||
|
33
src/pit.nim
33
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
|
||||||
@ -250,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:
|
||||||
|
|
||||||
@ -513,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.11.1"
|
const PIT_VERSION* = "4.12.0"
|
Loading…
x
Reference in New Issue
Block a user