4 Commits
1.0.1 ... 1.0.5

3 changed files with 22 additions and 13 deletions

View File

@ -1 +1 @@
const PTK_VERSION* = "1.0.1" const PTK_VERSION* = "1.0.5"

24
ptk.nim
View File

@ -123,10 +123,12 @@ proc doInit(timelineLocation: string): void =
type ExpectedMarkPart = enum Time, Summary, Tags, Notes type ExpectedMarkPart = enum Time, Summary, Tags, Notes
proc edit(mark: var Mark): void = proc edit(mark: Mark): Mark =
## Interactively edit a mark using the editor named in the environment ## Interactively edit a mark using the editor named in the environment
## variable "EDITOR" ## variable "EDITOR"
result = mark
var var
tempFile: File tempFile: File
tempFileName: string tempFileName: string
@ -142,22 +144,26 @@ proc edit(mark: var Mark): void =
tempFile.writeLine( tempFile.writeLine(
"""# Everything from the line below to the end of the file will be considered """# Everything from the line below to the end of the file will be considered
# notes for this timeline mark.""") # notes for this timeline mark.""")
tempFile.write(mark.notes)
close(tempFile) close(tempFile)
tempFile = nil
discard os.execShellCmd "$EDITOR " & tempFileName & " </dev/tty >/dev/tty" discard os.execShellCmd "$EDITOR " & tempFileName & " </dev/tty >/dev/tty"
var markPart = Time var markPart = Time
var notes: seq[string] = @[]
for line in lines tempFileName: for line in lines tempFileName:
if strip(line)[0] == '#': continue if strip(line).len > 0 and strip(line)[0] == '#': continue
elif markPart == Time: mark.time = parseTime(line); markPart = Summary elif markPart == Time: result.time = parseTime(line); markPart = Summary
elif markPart == Summary: mark.summary = line; markPart = Tags elif markPart == Summary: result.summary = line; markPart = Tags
elif markPart == Tags: elif markPart == Tags:
mark.tags = line.split({',', ';'}); result.tags = line.split({',', ';'});
markPart = Notes markPart = Notes
else: mark.notes &= line & "\x0D\x0A" else: notes.add(line)
result.notes = notes.join("\n")
finally: close(tempFile) finally: close(tempFile)
proc filterMarkIndices(timeline: Timeline, args: Table[string, Value]): seq[int] = proc filterMarkIndices(timeline: Timeline, args: Table[string, Value]): seq[int] =
@ -424,7 +430,7 @@ Options:
notes: args["--notes"] ?: "", notes: args["--notes"] ?: "",
tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isNilOrWhitespace)) tags: (args["--tags"] ?: "").split({',', ';'}).filterIt(not it.isNilOrWhitespace))
if args["--edit"]: edit(newMark) if args["--edit"]: newMark = edit(newMark)
let prevLastIdx = timeline.marks.getLastIndex() let prevLastIdx = timeline.marks.getLastIndex()
timeline.marks.add(newMark) timeline.marks.add(newMark)
@ -454,7 +460,7 @@ Options:
notes: markToResume.notes, notes: markToResume.notes,
tags: markToResume.tags) tags: markToResume.tags)
if args["--edit"]: edit(newMark) if args["--edit"]: newMark = edit(newMark)
timeline.marks.add(newMark) timeline.marks.add(newMark)
timeline.writeMarks( timeline.writeMarks(
@ -491,7 +497,7 @@ Options:
except: raise newException(ValueError, except: raise newException(ValueError,
"invalid value for --time: " & getCurrentExceptionMsg()) "invalid value for --time: " & getCurrentExceptionMsg())
if args["--edit"]: edit(mark) if args["--edit"]: mark = edit(mark)
timeline.marks.delete(markIdx) timeline.marks.delete(markIdx)
timeline.marks.insert(mark, markIdx) timeline.marks.insert(mark, markIdx)

View File

@ -1,7 +1,6 @@
# Package # Package
include "private/version.nim"
version = PTK_VERSION version = "1.0.5"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Personal Time Keeper" description = "Personal Time Keeper"
license = "MIT" license = "MIT"
@ -19,5 +18,9 @@ requires @[
"jester 0.4.1", "jester 0.4.1",
"https://git.jdb-labs.com/jdb/nim-lang-utils.git", "https://git.jdb-labs.com/jdb/nim-lang-utils.git",
"https://git.jdb-labs.com/jdb/nim-cli-utils.git", "https://git.jdb-labs.com/jdb/nim-cli-utils.git",
"https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.5.2" "https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.5.2",
"https://git.jdb-labs.com/jdb/update-nim-package-version"
] ]
task updateVersion, "Update the version of this package.":
exec "update_nim_package_version ptk 'private/version.nim'"