diff options
-rw-r--r-- | KeyRing.hs | 18 | ||||
-rw-r--r-- | kiki.hs | 6 |
2 files changed, 21 insertions, 3 deletions
@@ -10,6 +10,8 @@ module KeyRing | |||
10 | , KikiResult(..) | 10 | , KikiResult(..) |
11 | , KikiCondition(..) | 11 | , KikiCondition(..) |
12 | , KikiReportAction(..) | 12 | , KikiReportAction(..) |
13 | , errorString | ||
14 | , reportString | ||
13 | , KeyRingRuntime(..) | 15 | , KeyRingRuntime(..) |
14 | , InputFile(..) | 16 | , InputFile(..) |
15 | , FileType(..) | 17 | , FileType(..) |
@@ -394,6 +396,22 @@ data KikiReportAction = | |||
394 | | HostsDiff ByteString | 396 | | HostsDiff ByteString |
395 | deriving Show | 397 | deriving Show |
396 | 398 | ||
399 | uncamel :: String -> String | ||
400 | uncamel str = unwords $ firstWord ++ (toLower .: otherWords) ++ args | ||
401 | where | ||
402 | (.:) = fmap . fmap | ||
403 | ( firstWord , | ||
404 | otherWords ) = splitAt 1 ws | ||
405 | ws = camel >>= groupBy (\_ c -> isLower c) | ||
406 | ( camel, args) = splitAt 1 $ words str | ||
407 | |||
408 | reportString :: KikiReportAction -> String | ||
409 | reportString x = uncamel $ show x | ||
410 | |||
411 | errorString :: KikiCondition a -> String | ||
412 | errorString (KikiSuccess {}) = "success" | ||
413 | errorString e = uncamel . show $ fmap (const ()) e | ||
414 | |||
397 | data KikiResult a = KikiResult | 415 | data KikiResult a = KikiResult |
398 | { kikiCondition :: KikiCondition a | 416 | { kikiCondition :: KikiCondition a |
399 | , kikiReport :: [ (FilePath, KikiReportAction) ] | 417 | , kikiReport :: [ (FilePath, KikiReportAction) ] |
@@ -750,10 +750,10 @@ main = do | |||
750 | shargs = mapMaybe (\(x:xs) -> (,xs) <$> Map.lookup x shspec) sargs | 750 | shargs = mapMaybe (\(x:xs) -> (,xs) <$> Map.lookup x shspec) sargs |
751 | 751 | ||
752 | forM_ shargs $ \(cmd,args) -> cmd args (rtKeyDB rt) | 752 | forM_ shargs $ \(cmd,args) -> cmd args (rtKeyDB rt) |
753 | e -> print (void e)--(fmap (const ()) e) | 753 | e -> putStrLn $ errorString e |
754 | 754 | ||
755 | print report | 755 | forM_ report $ \(fname,act) -> do |
756 | return() | 756 | putStrLn $ fname ++ ": " ++ reportString act |
757 | where | 757 | where |
758 | 758 | ||
759 | doAutosign rt kd@(KeyData k ksigs umap submap) = ops | 759 | doAutosign rt kd@(KeyData k ksigs umap submap) = ops |