passwurrd now recursively walks directories
This commit is contained in:
parent
582bc2795f
commit
ce07da510b
1 changed files with 10 additions and 7 deletions
|
@ -4,14 +4,17 @@ import std/[os,osproc,re,strutils]
|
||||||
const pw_store = getHomeDir() & ".password-store/"
|
const pw_store = getHomeDir() & ".password-store/"
|
||||||
var passwords: seq[string] = @[]
|
var passwords: seq[string] = @[]
|
||||||
let gpg_re = re("(" & pw_store & "|\\.gpg)")
|
let gpg_re = re("(" & pw_store & "|\\.gpg)")
|
||||||
proc getPasswords(): seq[string] =
|
|
||||||
for dir in walkDir(pw_store):
|
proc parseFiles(path: string) =
|
||||||
if dir.kind == pcFile:
|
for file in walkDir(path):
|
||||||
continue
|
|
||||||
for file in walkDir(dir.path):
|
|
||||||
if file.path.endsWith(".gpg"):
|
if file.path.endsWith(".gpg"):
|
||||||
let pw = replace(file.path,gpg_re,"")
|
let pw = replace(file.path, gpg_re,"")
|
||||||
passwords.add(pw)
|
passwords.add(pw)
|
||||||
|
elif file.kind == pcDir:
|
||||||
|
parseFiles(file.path)
|
||||||
|
|
||||||
|
proc getPasswords(): seq[string] =
|
||||||
|
parseFiles(pw_store)
|
||||||
return passwords
|
return passwords
|
||||||
|
|
||||||
proc passwordToClipboard(password: string) =
|
proc passwordToClipboard(password: string) =
|
||||||
|
|
Loading…
Reference in a new issue