diff options
author | joe <joe@jerkface.net> | 2013-08-14 23:53:42 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-08-14 23:53:42 -0400 |
commit | 598b5b2cceb477a27c5ad981f52231556cbd58b9 (patch) | |
tree | 2acd1c0256edb7d258a6033cfa12677306a37f68 /keys.hs | |
parent | e73dd432d7e4a518466263ab3cc16bff6c4dfeac (diff) |
Moar
Diffstat (limited to 'keys.hs')
-rw-r--r-- | keys.hs | 38 |
1 files changed, 31 insertions, 7 deletions
@@ -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 | ||
535 | data Keys = | 535 | data 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 | ||
540 | main = do | 540 | main = 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 | ||