From ce07da510b6baddfa71b5df7d76cbfecaafc5a58 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 24 Oct 2022 10:00:56 +0100 Subject: [PATCH] passwurrd now recursively walks directories --- passwurrd/src/passwurrd.nim | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/passwurrd/src/passwurrd.nim b/passwurrd/src/passwurrd.nim index cd2e468..618ec62 100644 --- a/passwurrd/src/passwurrd.nim +++ b/passwurrd/src/passwurrd.nim @@ -4,14 +4,17 @@ import std/[os,osproc,re,strutils] const pw_store = getHomeDir() & ".password-store/" var passwords: seq[string] = @[] let gpg_re = re("(" & pw_store & "|\\.gpg)") + +proc parseFiles(path: string) = + for file in walkDir(path): + if file.path.endsWith(".gpg"): + let pw = replace(file.path, gpg_re,"") + passwords.add(pw) + elif file.kind == pcDir: + parseFiles(file.path) + proc getPasswords(): seq[string] = - for dir in walkDir(pw_store): - if dir.kind == pcFile: - continue - for file in walkDir(dir.path): - if file.path.endsWith(".gpg"): - let pw = replace(file.path,gpg_re,"") - passwords.add(pw) + parseFiles(pw_store) return passwords proc passwordToClipboard(password: string) =