Skip to content

Commit 0293e5c

Browse files
author
Joe Reynolds
committed
Use limit flag in recent
1 parent 4bf92c5 commit 0293e5c

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/subcommands/recent.nim

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
import std/[algorithm, parsecfg, times]
1+
import std/[algorithm, parsecfg, parseopt, strutils, times]
22
import ../[console, config, files]
33

44
const aliases* = @["r", "re", "recent"]
55

66
proc process*(config: Config, flags: seq[string]) =
77

8+
var limit = 15
9+
10+
for kind, key, val in getopt():
11+
case kind
12+
of cmdShortOption, cmdLongOption:
13+
case key
14+
of "l", "limit":
15+
limit = parseInt(val)
16+
else:
17+
discard
18+
819
let notes = getFilesforDir(getNotesPath(config))
920
let byTime = notes.sortedByIt(it.modifiedTime).reversed()
1021

11-
# TODO - use --limit flag here
12-
for note in byTime[0 .. 15]:
22+
for note in byTime[0 .. limit - 1]:
1323
stdout.write(note.name)
14-
info("(" & $note.modifiedTime & ")")
24+
25+
let mtime = $note.modifiedTime.format("YYYY-MM-dd HH:mm:ss")
26+
info(" (" & mtime & ")")
1527

1628

0 commit comments

Comments
 (0)