diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-19 03:04:17 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-19 03:04:17 +0300 |
commit | 58cd3d85f28c6dd79a8ddc5d315da5f2717cb32c (patch) | |
tree | ed3d8f1aa86cb6ec2b1c993bfec069e3a2051602 | |
parent | README update (diff) | |
download | windows-env-58cd3d85f28c6dd79a8ddc5d315da5f2717cb32c.tar.gz windows-env-58cd3d85f28c6dd79a8ddc5d315da5f2717cb32c.zip |
refactoring
-rw-r--r-- | apps/PromptMessage.hs | 21 |
1 files 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 |