REF refactor code
This commit is contained in:
parent
a5ef68ffc8
commit
1bd882b57f
|
@ -487,24 +487,19 @@ runPromptLoop n pwd = do
|
||||||
else return res
|
else return res
|
||||||
|
|
||||||
configToPwd :: PasswordConfig -> PasswordGetter
|
configToPwd :: PasswordConfig -> PasswordGetter
|
||||||
configToPwd PasswordConfig{ _passwordBitwarden = b
|
configToPwd PasswordConfig
|
||||||
, _passwordLibSecret = s
|
{ _passwordBitwarden = b
|
||||||
, _passwordPrompt = p
|
, _passwordLibSecret = s
|
||||||
} =
|
, _passwordPrompt = p
|
||||||
|
} =
|
||||||
getBW b `runMaybe` getLS s `runMaybe` getPrompt p
|
getBW b `runMaybe` getLS s `runMaybe` getPrompt p
|
||||||
where
|
where
|
||||||
getBW (Just BitwardenConfig{ _bitwardenKey = k, _bitwardenTries = n }) =
|
getBW (Just BitwardenConfig{ _bitwardenKey = k, _bitwardenTries = n }) =
|
||||||
runPromptLoop n $ runBitwarden k
|
runPromptLoop n $ runBitwarden k
|
||||||
getBW _ = return Nothing
|
getBW _ = return Nothing
|
||||||
getLS (Just LibSecretConfig{ _libsecretAttributes = a }) =
|
getLS = maybe (return Nothing) (runSecret . M.toList . _libsecretAttributes)
|
||||||
runSecret $ M.toList a
|
getPrompt = maybe (return Nothing) (flip runPromptLoop readPassword . _promptTries)
|
||||||
getLS _ = return Nothing
|
runMaybe x y = (\r -> if isNothing r then y else return r) =<< x
|
||||||
getPrompt (Just PromptConfig{ _promptTries = n }) =
|
|
||||||
runPromptLoop n readPassword
|
|
||||||
getPrompt _ = return Nothing
|
|
||||||
runMaybe x y = do
|
|
||||||
res <- x
|
|
||||||
if isNothing res then y else return res
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | Removable devices
|
-- | Removable devices
|
||||||
|
|
Loading…
Reference in New Issue