From 58cd3d85f28c6dd79a8ddc5d315da5f2717cb32c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 19 Jul 2016 03:04:17 +0300 Subject: refactoring --- apps/PromptMessage.hs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/PromptMessage.hs b/apps/PromptMessage.hs index 226a090..5ed7c4b 100644 --- a/apps/PromptMessage.hs +++ b/apps/PromptMessage.hs @@ -9,25 +9,26 @@ module PromptMessage , wipeMessage ) where -import Data.Maybe (fromJust, isJust) +import Data.Maybe (isJust) import Text.Printf (printf) import qualified Windows.Environment as Env engraveMessage :: Env.Profile -> Env.VarName -> Maybe Env.VarValue -> Env.VarValue -> String engraveMessage profile name oldValue newValue = - warning ++ values + descriptionMsg ++ oldValueMsg ++ newValueMsg where - warning = printf "Saving variable '%s' to '%s'...\n" name $ Env.profileKeyPath profile + profileKey = Env.profileKeyPath profile - values - | isJust oldValue = oldValueMsg ++ newValueMsg - | otherwise = valueMsg + descriptionMsg = printf "Saving variable '%s' to '%s'...\n" name profileKey - oldValueMsg = printf "\tOld value: %s\n" $ fromJust oldValue - newValueMsg = printf "\tNew value: %s\n" newValue - valueMsg = printf "\tValue: %s\n" newValue + oldValueMsg = maybe "" (printf "\tOld value: %s\n") oldValue + newValueMsg + | isJust oldValue = printf "\tNew value: %s\n" newValue + | otherwise = printf "\tValue: %s\n" newValue wipeMessage :: Env.Profile -> Env.VarName -> String wipeMessage profile name = - printf "Deleting variable '%s' from '%s'...\n" name $ Env.profileKeyPath profile + printf "Deleting variable '%s' from '%s'...\n" name profileKey + where + profileKey = Env.profileKeyPath profile -- cgit v1.2.3