summaryrefslogtreecommitdiff
path: root/keys.hs
diff options
context:
space:
mode:
Diffstat (limited to 'keys.hs')
-rw-r--r--keys.hs38
1 files changed, 31 insertions, 7 deletions
diff --git a/keys.hs b/keys.hs
index 5f0da17..4eb9603 100644
--- a/keys.hs
+++ b/keys.hs
@@ -532,16 +532,40 @@ multiCommand ti choices =
532 strip (cmd,(action,_)) = fmap (cmd,) action 532 strip (cmd,(action,_)) = fmap (cmd,) action
533-} 533-}
534 534
535data Keys = 535data Arguments =
536 List 536 List
537 | AutoSign {input :: FilePath, output :: FilePath} 537 | AutoSign {input :: FilePath, output :: FilePath}
538 deriving (Show, Data, Typeable) 538 deriving (Show, Data, Typeable)
539 539
540main = do 540main = do
541 args <- cmdArgs $ modes [List &= help "list keys",AutoSign (def &= argPos 1 541 args <- cmdArgs $ modes
542 &= typFile ) 542 [ List &= help "list key pairs for which secrets are known"
543 (def &=argPos 2 543 &= auto
544 &= typFile)] 544 , AutoSign (def &= argPos 1 &= typFile ) (def &=argPos 2 &= typFile)
545 &= summary "keys - a pgp key editing utility" 545 &= help "auto-sign tor-style uids" ]
546 putStrLn $ show args 546 &= program "keys"
547 &= summary "keys - a pgp key editing utility"
548 doCmd args
549 where
550 envhomedir opt = do
551 gnupghome <- lookupEnv homevar >>=
552 \d -> return $ d >>= guard . (/="") >> d
553 home <- flip fmap getHomeDirectory $
554 \d -> fmap (const d) $ guard (d/="")
555 let homegnupg = (++('/':appdir)) <$> home
556 let val = (opt `mplus` gnupghome `mplus` homegnupg)
557 return $ val
558
559 homevar = "GNUPGHOME"
560 appdir = ".gnupg"
561
562 doCmd List = do
563 homedir <- envhomedir Nothing
564 flip (maybe (putStrLn "Could not find home directory."))
565 homedir $ \homedir -> do
566 -- putStrLn $ "homedir = " ++show homedir
567 let secring = homedir ++ "/" ++ "secring.gpg"
568 -- putStrLn $ "secring = " ++ show secring
569 (Message msg) <- readPacketsFromFile secring
570 putStrLn $ listKeys msg
547 571