diff options
Diffstat (limited to 'Gpg.hs')
-rw-r--r-- | Gpg.hs | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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" |