diff --git a/src/Main.hs b/src/Main.hs index 4848314..5c177ee 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,6 +2,7 @@ module Main where +import Control.Exception import Control.Monad import qualified Data.ByteString as B import qualified Data.ByteString.Base64 as B64 @@ -26,7 +27,11 @@ main = do _ -> sign encrypt = do - encryptedFile <- T.encodeUtf8 <$> getPrivateKey + let key = catch getPrivateKey + (\e -> do let err = show (e :: IOException) + hPutStr stderr ("Warning: Couldn't get key from file (" ++ err ++ "), reading from stdin\n") + T.getContents) + encryptedFile <- T.encodeUtf8 <$> key path <- getPrivateKeyPath B.writeFile path =<< encryptData encryptedFile