-
-
Save benjacoblee/32f111f659765fdb7f9a91ab6a0ba4f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/private/osdirs | |
import std/os | |
import std/times | |
import std/algorithm | |
import std/terminal | |
import unpack | |
var table: seq[(string, Time)] = @[] | |
if paramCount() > 0: | |
commandLineParams().unpackSeq(path) | |
if dirExists(path): | |
try: | |
for fName in walkDirRec(path, skipSpecial = true): | |
var entry = (fName, getLastModificationTime(fName)) | |
table.add(entry) | |
except OSError: discard | |
finally: | |
proc myCmp(x, y: (string, Time)): int = | |
var (_, t1) = x | |
var (_, t2) = y | |
cmp(t1, t2) | |
table.sort(myCmp) | |
for (fName, mTime) in table: | |
let dt = format(mTime, "yyyy-MM-dd HH:mm") | |
styledEcho fName, " ", styleBright, fgYellow, dt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment