Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d75f5607c2 | |||
15708cebdf | |||
78a35b6478 |
8
private/ptkutil.nim
Normal file
8
private/ptkutil.nim
Normal file
@ -0,0 +1,8 @@
|
||||
template first*(a: openarray): auto = a[0]
|
||||
|
||||
template last*(a: openarray): auto = a[len(a)-1]
|
||||
|
||||
proc flatten*[T](a: seq[seq[T]]): seq[T] =
|
||||
result = @[]
|
||||
for subseq in a:
|
||||
result.add(subseq)
|
22
ptk.nim
22
ptk.nim
@ -6,7 +6,7 @@
|
||||
import algorithm, docopt, json, langutils, logging, os, nre, sequtils,
|
||||
sets, strutils, tempfile, terminal, times, timeutils, uuids
|
||||
|
||||
import ptkutil
|
||||
import private/ptkutil
|
||||
|
||||
type
|
||||
Mark* = tuple[id: UUID, time: TimeInfo, summary: string, notes: string, tags: seq[string]]
|
||||
@ -347,6 +347,7 @@ Usage:
|
||||
ptk continue
|
||||
ptk delete <id>
|
||||
ptk (list | ls) [options]
|
||||
ptk (list | ls) tags
|
||||
ptk sum-time --ids <ids>...
|
||||
ptk sum-time [options] [<firstId>] [<lastId>]
|
||||
ptk (-V | --version)
|
||||
@ -379,7 +380,7 @@ Options:
|
||||
let now = getLocalTime(getTime())
|
||||
|
||||
# Parse arguments
|
||||
let args = docopt(doc, version = "ptk 0.8.0")
|
||||
let args = docopt(doc, version = "ptk 0.10.0")
|
||||
|
||||
if args["--echo-args"]: echo $args
|
||||
|
||||
@ -513,7 +514,8 @@ Options:
|
||||
let prevLastIdx = timeline.marks.getLastIndex()
|
||||
timeline.marks.add(newMark)
|
||||
timeline.writeMarks(
|
||||
indices = @[prevLastIdx, timeline.marks.len - 1],
|
||||
indices = if prevLastIdx < 0: @[0]
|
||||
else: @[prevLastIdx, timeline.marks.len - 1],
|
||||
includeNotes = args["--verbose"])
|
||||
|
||||
saveTimeline(timeline, timelineLocation)
|
||||
@ -525,7 +527,9 @@ Options:
|
||||
if args["<id>"]:
|
||||
markToResumeIdx = timeline.marks.findById($args["<id>"])
|
||||
if markToResumeIdx == -1: exitErr "Cannot find a mark matching " & $args["<id>"]
|
||||
else: markToResumeIdx = timeline.marks.getLastIndex()
|
||||
else:
|
||||
markToResumeIdx = timeline.marks.getLastIndex()
|
||||
if markToResumeIdx < 0: exitErr "No mark to resume."
|
||||
var markToResume = timeline.marks[markToResumeIdx]
|
||||
|
||||
var newMark: Mark = (
|
||||
@ -552,7 +556,9 @@ Options:
|
||||
if args["<id>"]:
|
||||
markIdx = timeline.marks.findById($args["<id>"])
|
||||
if markIdx == -1: exitErr "Cannot find a mark matching " & $args["<id>"]
|
||||
else: markIdx = timeline.marks.getLastIndex()
|
||||
else:
|
||||
markIdx = timeline.marks.getLastIndex()
|
||||
if markIdx < 0: exitErr "No mark to amend."
|
||||
|
||||
var mark = timeline.marks[markIdx]
|
||||
|
||||
@ -590,6 +596,12 @@ Options:
|
||||
|
||||
if args["list"] or args["ls"]:
|
||||
|
||||
if args["tags"]:
|
||||
|
||||
echo $(timeline.marks.mapIt(it.tags)
|
||||
.flatten().deduplicate().sorted(system.cmp).join("\n"))
|
||||
|
||||
else:
|
||||
var selectedIndices = timeline.filterMarkIndices(args)
|
||||
|
||||
timeline.writeMarks(
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "0.8.0"
|
||||
version = "0.10.0"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Personal Time Keeper"
|
||||
license = "MIT"
|
||||
@ -8,5 +8,5 @@ bin = @["ptk"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires @["nim >= 0.15.0", "docopt >= 0.6.4", "uuids", "langutils", "tempfile", "timeutils >= 0.2.0"]
|
||||
requires @["nim >= 0.15.0", "docopt >= 0.6.4", "uuids", "langutils", "tempfile", "timeutils >= 0.2.0", "isaac >= 0.1.2"]
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
template first*(a: openarray): auto = a[0]
|
||||
|
||||
template last*(a: openarray): auto = a[len(a)-1]
|
Reference in New Issue
Block a user