diff options
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 72 |
1 files changed, 30 insertions, 42 deletions
@@ -1179,6 +1179,32 @@ sync bExport bImport bSecret cmdarg args_raw = do | |||
1179 | putStrLn $ fname ++ ": " ++ reportString act | 1179 | putStrLn $ fname ++ ": " ++ reportString act |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | doTransform :: [String] -> ([String]->[Transform]) -> IO () | ||
1183 | doTransform args mktrans = do | ||
1184 | let (sargs,margs) = processArgs sargspec polyVariadicArgs "---" args | ||
1185 | where sargspec = [] | ||
1186 | polyVariadicArgs = ["---"] | ||
1187 | passfd = fmap (FileDesc . read) passphrase_fd | ||
1188 | where passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs | ||
1189 | targs = fromMaybe [] $ Map.lookup "---" margs | ||
1190 | homespec = join . take 1 <$> Map.lookup "--homedir" margs | ||
1191 | kikiOp = KeyRingOperation | ||
1192 | { opFiles = Map.fromList $ | ||
1193 | [ ( HomeSec, buildStreamInfo KF_All KeyRingFile ) | ||
1194 | , ( HomePub, buildStreamInfo KF_All KeyRingFile ) | ||
1195 | ] | ||
1196 | , opPassphrases = withAgent $ do pfile <- maybeToList passfd | ||
1197 | return $ PassphraseSpec Nothing Nothing pfile | ||
1198 | , opTransforms = mktrans targs | ||
1199 | , opHome = homespec | ||
1200 | } | ||
1201 | KikiResult rt report <- runKeyRing kikiOp | ||
1202 | forM_ report $ \(fname,act) -> do | ||
1203 | putStrLn $ fname ++ ": " ++ reportString act | ||
1204 | case rt of | ||
1205 | KikiSuccess _ -> return () | ||
1206 | err -> putStrLn $ errorString err | ||
1207 | |||
1182 | kiki :: String -> [String] -> IO () | 1208 | kiki :: String -> [String] -> IO () |
1183 | kiki "sync-secret" args_raw = | 1209 | kiki "sync-secret" args_raw = |
1184 | sync True True True "sync-secret" args_raw | 1210 | sync True True True "sync-secret" args_raw |
@@ -1532,27 +1558,8 @@ kiki "delete" args | "--help" `elem` args = do | |||
1532 | , " with all associated signatures and trust markers." | 1558 | , " with all associated signatures and trust markers." |
1533 | ] | 1559 | ] |
1534 | return () | 1560 | return () |
1535 | kiki "delete" args = do | 1561 | kiki "delete" args = doTransform args delete |
1536 | let (sargs,margs) = processArgs sargspec polyVariadicArgs "--delete" args | 1562 | where delete fps = map DeleteSubkeyByFingerprint fps |
1537 | where sargspec = [] | ||
1538 | polyVariadicArgs = ["--delete"] | ||
1539 | passfd = fmap (FileDesc . read) passphrase_fd | ||
1540 | where passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs | ||
1541 | fps = fromMaybe [] $ Map.lookup "--delete" margs | ||
1542 | homespec = join . take 1 <$> Map.lookup "--homedir" margs | ||
1543 | kikiOp = KeyRingOperation | ||
1544 | { opFiles = Map.fromList $ | ||
1545 | [ ( HomeSec, buildStreamInfo KF_All KeyRingFile ) | ||
1546 | , ( HomePub, buildStreamInfo KF_All KeyRingFile ) | ||
1547 | ] | ||
1548 | , opPassphrases = withAgent $ do pfile <- maybeToList passfd | ||
1549 | return $ PassphraseSpec Nothing Nothing pfile | ||
1550 | , opTransforms = map DeleteSubkeyByFingerprint fps | ||
1551 | , opHome = homespec | ||
1552 | } | ||
1553 | KikiResult rt report <- runKeyRing kikiOp | ||
1554 | forM_ report $ \(fname,act) -> do | ||
1555 | putStrLn $ fname ++ ": " ++ reportString act | ||
1556 | 1563 | ||
1557 | kiki "rename" args | "--help" `elem` args = do | 1564 | kiki "rename" args | "--help" `elem` args = do |
1558 | putStr . unlines $ | 1565 | putStr . unlines $ |
@@ -1562,28 +1569,9 @@ kiki "rename" args | "--help" `elem` args = do | |||
1562 | , " The old signature will be replaced and a new one formed." | 1569 | , " The old signature will be replaced and a new one formed." |
1563 | ] | 1570 | ] |
1564 | return () | 1571 | return () |
1565 | kiki "rename" args = do | ||
1566 | let (sargs,margs) = processArgs sargspec polyVariadicArgs "--rename" args | ||
1567 | where sargspec = [("--homedir",1)] | ||
1568 | polyVariadicArgs = ["--rename"] | ||
1569 | passfd = fmap (FileDesc . read) passphrase_fd | ||
1570 | where passphrase_fd = concat <$> Map.lookup "--passphrase-fd" margs | ||
1571 | (oldtag:newtag:_) = fromMaybe [] $ Map.lookup "--rename" margs | ||
1572 | homespec = join . take 1 <$> Map.lookup "--homedir" margs | ||
1573 | kikiOp = KeyRingOperation | ||
1574 | { opFiles = Map.fromList $ | ||
1575 | [ ( HomeSec, buildStreamInfo KF_All KeyRingFile ) | ||
1576 | , ( HomePub, buildStreamInfo KF_All KeyRingFile ) | ||
1577 | ] | ||
1578 | , opPassphrases = withAgent $ do pfile <- maybeToList passfd | ||
1579 | return $ PassphraseSpec Nothing Nothing pfile | ||
1580 | , opTransforms = [ RenameSubkeys oldtag newtag] | ||
1581 | , opHome = homespec | ||
1582 | } | ||
1583 | KikiResult rt report <- runKeyRing kikiOp | ||
1584 | forM_ report $ \(fname,act) -> do | ||
1585 | putStrLn $ fname ++ ": " ++ reportString act | ||
1586 | 1572 | ||
1573 | kiki "rename" args = doTransform args rename | ||
1574 | where rename (oldtag:newtag:_) = [ RenameSubkeys oldtag newtag ] | ||
1587 | 1575 | ||
1588 | kiki "tar" args | "--help" `elem` args = do | 1576 | kiki "tar" args | "--help" `elem` args = do |
1589 | putStr . unlines $ | 1577 | putStr . unlines $ |