aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/Banner.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-18 00:43:21 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-18 00:43:21 +0300
commitbe9299d2dc8e0a9e76fe6f07cabb15c144999710 (patch)
tree91a68cd35e78c612eb358181f24e91fda904e766 /apps/Banner.hs
parentput modules to 'Windows' (diff)
downloadwindows-env-be9299d2dc8e0a9e76fe6f07cabb15c144999710.tar.gz
windows-env-be9299d2dc8e0a9e76fe6f07cabb15c144999710.zip
refactoring
Diffstat (limited to 'apps/Banner.hs')
-rw-r--r--apps/Banner.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/Banner.hs b/apps/Banner.hs
new file mode 100644
index 0000000..c25741b
--- /dev/null
+++ b/apps/Banner.hs
@@ -0,0 +1,31 @@
+{-
+ - Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com>
+ - This file is licensed under the terms of the MIT License.
+ - See LICENSE.txt for details.
+-}
+
+module Banner
+ ( engraveBanner
+ , wipeBanner
+ ) where
+
+import Data.Maybe (fromJust, isJust)
+import Text.Printf (printf)
+
+import qualified Windows.Environment as Env
+
+engraveBanner :: Env.Profile -> Env.VarName -> Maybe Env.VarValue -> Env.VarValue -> String
+engraveBanner profile name oldValue newValue =
+ warning ++ valuesStr
+ where
+ warning = printf "Saving variable '%s' to '%s'...\n" name (Env.profileKeyPath profile)
+ valuesStr
+ | isJust oldValue = oldValueStr ++ newValueStr
+ | otherwise = theValueStr
+ oldValueStr = printf "\tOld value: %s\n" $ fromJust oldValue
+ newValueStr = printf "\tNew value: %s\n" newValue
+ theValueStr = printf "\tValue: %s\n" newValue
+
+wipeBanner :: Env.Profile -> Env.VarName -> String
+wipeBanner profile name =
+ printf "Deleting variable '%s' from '%s'...\n" name (Env.profileKeyPath profile)