From fc67f3938b64b35ec6dc71ba171507c03adcab88 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 7 Jul 2015 22:09:46 +0200 Subject: [PATCH] Make getKeychain parametric --- src/Main.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 4cd6063..5937adb 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -39,13 +39,12 @@ keychainList :: IO [FilePath] keychainList = do raw <- readProcess "security" ["list-keychains"] "" case runParser parseKeychainList raw of - Just list -> return list + Just list -> return $ filter ((/="System") . takeBaseName) list Nothing -> error "failed to parse active keychains list" -getKeychain :: IO Keychain -getKeychain = do - paths <- filter ((/="System") . takeBaseName) <$> keychainList - raw <- readProcess "security" ("dump-keychain" : "-d" : paths) "" +getKeychain :: [FilePath] -> IO Keychain +getKeychain paths = do + raw <- readProcess "security" ("dump-keychain" : "-d" : paths) "" case runParser parseKeychain raw of Just items -> return items Nothing -> error "failed to parse keychain"