From dbd2a5be2baee8cec404a759a9407f94ab9f656e Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 12 Jun 2022 04:53:04 +0200 Subject: [PATCH] improve output messages --- src/Main.hs | 15 +++++++++++---- src/lib/Namecoin.hs | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 6d21d6f..fbb1b7a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -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 -- diff --git a/src/lib/Namecoin.hs b/src/lib/Namecoin.hs index 43c6eee..533801a 100644 --- a/src/lib/Namecoin.hs +++ b/src/lib/Namecoin.hs @@ -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