diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-11-06 11:50:16 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-11-06 11:50:16 -0400 |
commit | 2a555c479e078519b2e7d7b7258e6ba37ec3e22f (patch) | |
tree | c51663051d601cc59ea9d49ebcd5a26cdde91498 /Gpg.hs | |
parent | 9e0ca8324a28f38acc0deefa23fb056830fecf0a (diff) | |
download | keysafe-2a555c479e078519b2e7d7b7258e6ba37ec3e22f.tar.gz |
Defer requesting secret key from gpg until just before backup
So the user knows why gpg is asking for this secret key to be backed up.
Before, this was done as soon as keysafe started, which didn't give the
user any indication what was going on, unless they had multiple keys and so
picked the key to back up from a list.
This commit was sponsored by Thomas Hochstein on Patreon.
Diffstat (limited to 'Gpg.hs')
-rw-r--r-- | Gpg.hs | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -21,19 +21,17 @@ 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 (SecretKeySource, SecretKey) +getKeyToBackup :: UI -> IO SecretKeySource 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)] = mkret kid - go l = maybe (error "Canceled") mkret + go [(_, kid)] = selected kid + go l = maybe (error "Canceled") selected =<< promptKeyId ui "Pick gpg secret key" "Pick gpg secret key to back up:" l - mkret kid = do - sk <- getSecretKey kid - return (GpgKey kid, sk) + selected = return . GpgKey listSecretKeys :: IO [(Name, KeyId)] listSecretKeys = map mk . parse . lines <$> readProcess "gpg" |