diff options
-rw-r--r-- | kiki.hs | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -1622,20 +1622,20 @@ main = do | |||
1622 | let (args,trail1) = break (=="--") args_raw | 1622 | let (args,trail1) = break (=="--") args_raw |
1623 | trail = drop 1 trail1 | 1623 | trail = drop 1 trail1 |
1624 | (sargs,margs) = | 1624 | (sargs,margs) = |
1625 | (sargs, foldl' (\m (k:xs)->Map.alter (appendArgs xs) k m) | 1625 | (sargs, foldl' (\m (k:xs)->Map.alter (appendArgs k xs) k m) |
1626 | Map.empty | 1626 | Map.empty |
1627 | gargs) | 1627 | gargs) |
1628 | where (sargs,vargs) = partitionStaticArguments | 1628 | where (sargs,vargs) = partitionStaticArguments sargspec args |
1629 | [ ("--homedir",1) | 1629 | sargspec = [ ("--homedir",1) |
1630 | , ("--passphrase-fd",1) | 1630 | , ("--passphrase-fd",1) |
1631 | , ("--import",0) | 1631 | , ("--import",0) |
1632 | , ("--autosign",0) | 1632 | , ("--autosign",0) |
1633 | , ("--show-wk",0) | 1633 | , ("--show-wk",0) |
1634 | , ("--show-all",0) | 1634 | , ("--show-all",0) |
1635 | , ("--show-pem",1) | 1635 | , ("--show-pem",1) |
1636 | , ("--help",0) | 1636 | , ("--help",0) |
1637 | ] | 1637 | ] |
1638 | args | 1638 | argspec = map fst sargspec ++ ["--keyrings","--keypairs"] |
1639 | args' = if map (take 1) (take 1 vargs) == ["-"] | 1639 | args' = if map (take 1) (take 1 vargs) == ["-"] |
1640 | then vargs | 1640 | then vargs |
1641 | else "--keyrings":vargs | 1641 | else "--keyrings":vargs |
@@ -1643,7 +1643,11 @@ main = do | |||
1643 | . toLast (++trail) | 1643 | . toLast (++trail) |
1644 | . groupBy (\_ s-> take 1 s /= "-") | 1644 | . groupBy (\_ s-> take 1 s /= "-") |
1645 | $ args' | 1645 | $ args' |
1646 | appendArgs xs = Just . maybe xs (++xs) | 1646 | appendArgs k xs opt = |
1647 | if k `elem` argspec | ||
1648 | then Just . maybe xs (++xs) $ opt | ||
1649 | else error . unlines $ [ "unrecognized option "++k | ||
1650 | , "Use --help for usage." ] | ||
1647 | -- putStrLn $ "margs = " ++ show (Map.assocs margs) | 1651 | -- putStrLn $ "margs = " ++ show (Map.assocs margs) |
1648 | unkeysRef <- newIORef Map.empty | 1652 | unkeysRef <- newIORef Map.empty |
1649 | pwRef <- newIORef Nothing | 1653 | pwRef <- newIORef Nothing |