summaryrefslogtreecommitdiffhomepage
path: root/Gpg.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Gpg.hs')
-rw-r--r--Gpg.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/Gpg.hs b/Gpg.hs
index 8290c2f..91b53cd 100644
--- a/Gpg.hs
+++ b/Gpg.hs
@@ -21,20 +21,19 @@ import qualified Data.Text as T
--
-- If there is only one gpg secret key,
-- the choice is obvious. Otherwise prompt the user with a list.
-getKeyToBackup :: UI -> IO SecretKey
+getKeyToBackup :: UI -> IO (SecretKeySource, SecretKey)
getKeyToBackup ui = go =<< listSecretKeys
where
go [] = do
showError ui "You have no gpg secret keys to back up."
error "Aborting on no gpg secret keys."
- go [(_, kid)] = getSecretKey kid
- go l = maybe (error "Canceled") getSecretKey
+ go [(_, kid)] = mkret kid
+ go l = maybe (error "Canceled") mkret
=<< promptKeyId ui "Pick gpg secret key"
"Pick gpg secret key to back up:" l
-
--- | Use when the gpg keyid will not be known at restore time.
-anyKey :: SecretKeySource
-anyKey = GpgKey (KeyId "")
+ mkret kid = do
+ sk <- getSecretKey kid
+ return (GpgKey kid, sk)
listSecretKeys :: IO [(Name, KeyId)]
listSecretKeys = map mk . parse . lines <$> readProcess "gpg"