Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
72c332fa45 | |||
4a878026d8 | |||
ee733957c6 |
35
ptk.nim
35
ptk.nim
@ -154,6 +154,9 @@ proc writeMarks(timeline: Timeline, indices: seq[int], includeNotes = false): vo
|
|||||||
|
|
||||||
if prefix.len > longestPrefix: longestPrefix = prefix.len
|
if prefix.len > longestPrefix: longestPrefix = prefix.len
|
||||||
|
|
||||||
|
let colWidth = 80
|
||||||
|
let notesPrefixLen = 4
|
||||||
|
|
||||||
for w in toWrite:
|
for w in toWrite:
|
||||||
if w.mark.summary == STOP_MSG: continue
|
if w.mark.summary == STOP_MSG: continue
|
||||||
|
|
||||||
@ -174,7 +177,11 @@ proc writeMarks(timeline: Timeline, indices: seq[int], includeNotes = false): vo
|
|||||||
writeLine(stdout, "")
|
writeLine(stdout, "")
|
||||||
|
|
||||||
if includeNotes and len(w.mark.notes.strip) > 0:
|
if includeNotes and len(w.mark.notes.strip) > 0:
|
||||||
writeLine(stdout, spaces(longestPrefix) & w.mark.notes)
|
writeLine(stdout, "")
|
||||||
|
let wrappedNotes = wordWrap(s = w.mark.notes,
|
||||||
|
maxLineWidth = colWidth)
|
||||||
|
for line in splitLines(wrappedNotes):
|
||||||
|
writeLine(stdout, spaces(notesPrefixLen) & line)
|
||||||
writeLine(stdout, "")
|
writeLine(stdout, "")
|
||||||
|
|
||||||
proc formatMark(mark: Mark, nextMark = NO_MARK, timeFormat = ISO_TIME_FORMAT, includeNotes = false): string =
|
proc formatMark(mark: Mark, nextMark = NO_MARK, timeFormat = ISO_TIME_FORMAT, includeNotes = false): string =
|
||||||
@ -190,13 +197,12 @@ proc formatMark(mark: Mark, nextMark = NO_MARK, timeFormat = ISO_TIME_FORMAT, in
|
|||||||
# TODO: pick up here calculating the time between marks
|
# TODO: pick up here calculating the time between marks
|
||||||
|
|
||||||
let prefix = ($mark.id)[0..<8] & " " & mark.time.format(timeFormat) & " (" & duration & ") -- "
|
let prefix = ($mark.id)[0..<8] & " " & mark.time.format(timeFormat) & " (" & duration & ") -- "
|
||||||
let prefixLen = len(($mark.id)[0..<8] & " " & mark.time.format(timeFormat) & " (" & duration & ") -- ")
|
|
||||||
|
|
||||||
result = prefix & mark.summary
|
result = prefix & mark.summary
|
||||||
if includeNotes and len(mark.notes.strip()) > 0:
|
if includeNotes and len(mark.notes.strip()) > 0:
|
||||||
let wrappedNotes = wordWrap(s = mark.notes, maxLineWidth = 80 - prefixLen)
|
let wrappedNotes = wordWrap(s = mark.notes, maxLineWidth = 80 - prefix.len)
|
||||||
for line in splitLines(wrappedNotes):
|
for line in splitLines(wrappedNotes):
|
||||||
result &= "\x0D\x0A" & spaces(prefixLen) & line
|
result &= "\x0D\x0A" & spaces(prefix.len) & line
|
||||||
result &= "\x0D\x0A"
|
result &= "\x0D\x0A"
|
||||||
|
|
||||||
proc findById(marks: seq[Mark], id: string): int =
|
proc findById(marks: seq[Mark], id: string): int =
|
||||||
@ -338,8 +344,8 @@ when isMainModule:
|
|||||||
let doc = """
|
let doc = """
|
||||||
Usage:
|
Usage:
|
||||||
ptk init [options]
|
ptk init [options]
|
||||||
ptk add [options]
|
ptk (add | start) [options]
|
||||||
ptk add [options] <summary>
|
ptk (add | start) [options] <summary>
|
||||||
ptk resume [options] [<id>]
|
ptk resume [options] [<id>]
|
||||||
ptk amend [options] [<id>] [<summary>]
|
ptk amend [options] [<id>] [<summary>]
|
||||||
ptk merge <timeline> [<timeline>...]
|
ptk merge <timeline> [<timeline>...]
|
||||||
@ -348,6 +354,7 @@ Usage:
|
|||||||
ptk delete <id>
|
ptk delete <id>
|
||||||
ptk (list | ls) [options]
|
ptk (list | ls) [options]
|
||||||
ptk (list | ls) tags
|
ptk (list | ls) tags
|
||||||
|
ptk current
|
||||||
ptk sum-time --ids <ids>...
|
ptk sum-time --ids <ids>...
|
||||||
ptk sum-time [options] [<firstId>] [<lastId>]
|
ptk sum-time [options] [<firstId>] [<lastId>]
|
||||||
ptk (-V | --version)
|
ptk (-V | --version)
|
||||||
@ -380,7 +387,7 @@ Options:
|
|||||||
let now = getLocalTime(getTime())
|
let now = getLocalTime(getTime())
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
let args = docopt(doc, version = "ptk 0.10.0")
|
let args = docopt(doc, version = "ptk 0.11.2")
|
||||||
|
|
||||||
if args["--echo-args"]: echo $args
|
if args["--echo-args"]: echo $args
|
||||||
|
|
||||||
@ -500,7 +507,7 @@ Options:
|
|||||||
|
|
||||||
saveTimeline(timeline, timelineLocation)
|
saveTimeline(timeline, timelineLocation)
|
||||||
|
|
||||||
if args["add"]:
|
if args["add"] or args["start"]:
|
||||||
|
|
||||||
var newMark: Mark = (
|
var newMark: Mark = (
|
||||||
id: genUUID(),
|
id: genUUID(),
|
||||||
@ -606,7 +613,17 @@ Options:
|
|||||||
|
|
||||||
timeline.writeMarks(
|
timeline.writeMarks(
|
||||||
indices = selectedIndices,
|
indices = selectedIndices,
|
||||||
includeNotes = args["--version"])
|
includeNotes = args["--verbose"])
|
||||||
|
|
||||||
|
if args["current"]:
|
||||||
|
|
||||||
|
let idx = timeline.marks.len - 1
|
||||||
|
if timeline.marks[idx].summary == STOP_MSG:
|
||||||
|
echo "ptk: no current task"
|
||||||
|
else:
|
||||||
|
timeline.writeMarks(
|
||||||
|
indices = @[idx],
|
||||||
|
includeNotes = true)
|
||||||
|
|
||||||
if args["sum-time"]:
|
if args["sum-time"]:
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.10.0"
|
version = "0.11.2"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal Time Keeper"
|
description = "Personal Time Keeper"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@ -8,5 +8,5 @@ bin = @["ptk"]
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires @["nim >= 0.15.0", "docopt >= 0.6.4", "uuids", "langutils", "tempfile", "timeutils >= 0.2.0", "isaac >= 0.1.2"]
|
requires @["nim >= 0.18.0", "docopt >= 0.6.4", "uuids", "langutils", "tempfile", "timeutils >= 0.2.2", "isaac >= 0.1.2"]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user