improve output messages

master
Michele Guerini Rocco 2022-06-12 04:53:04 +02:00
parent cc0dfcde80
commit dbd2a5be2b
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 12 additions and 5 deletions

View File

@ -19,12 +19,19 @@ nameCheck uri = do
case names of
Left error -> putStrLn ("Name check failed. "++error)
Right names -> do
putStrLn ("Found "++show (length names)++" names:")
mapM (\i -> putStrLn $ " - "++name i) names
let expiring = filter isExpiring names
total = length expiring
failed <- sum <$> mapM (nameUpdate uri) expiring
if failed == 0
then putStrLn "Names updated: all ok."
else putStrLn (show failed ++ "/" ++ show total ++ " failed.")
if (total > 0) then do
putStrLn (show total++" names are expiring")
failed <- sum <$> mapM (nameUpdate uri) expiring
if failed == 0
then putStrLn "All names updated."
else putStrLn (show failed ++ "/" ++ show total ++ " failed.")
else
putStrLn "Nothing to update."
-- | Main function
--

View File

@ -152,4 +152,4 @@ nameUpdate uri (Name {..}) = do
req <- rpcRequest uri "name_update" [ name, value ]
case req of
Left err -> putStrLn "failed" >> putStrLn err >> return 1
Right _ -> putStrLn "ok" >> return 1
Right _ -> putStrLn "ok" >> return 0