aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/SetEnv.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-18 04:47:21 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-18 04:47:21 +0300
commit62f1e6b804a940506eff5f3f924d2d000e16119d (patch)
tree443872b2e8ba439cb77de95391bba9319449de08 /apps/SetEnv.hs
parentREADME update (diff)
downloadwindows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.tar.gz
windows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.zip
fix compiler warnings + refactoring
Diffstat (limited to 'apps/SetEnv.hs')
-rw-r--r--apps/SetEnv.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/SetEnv.hs b/apps/SetEnv.hs
index e94e350..482bb31 100644
--- a/apps/SetEnv.hs
+++ b/apps/SetEnv.hs
@@ -11,8 +11,8 @@ import Control.Monad (void)
import Options.Applicative
import qualified Windows.Environment as Env
-import Banner
import Prompt
+import PromptMessage
data Options = Options
{ optYes :: Bool
@@ -21,8 +21,8 @@ data Options = Options
, optValue :: Env.VarValue
} deriving (Eq, Show)
-options :: Parser Options
-options = Options
+optionParser :: Parser Options
+optionParser = Options
<$> optYesDesc
<*> optGlobalDesc
<*> optNameDesc
@@ -44,14 +44,12 @@ options = Options
main :: IO ()
main = execParser parser >>= setEnv
where
- parser = info (helper <*> options) $
+ parser = info (helper <*> optionParser) $
fullDesc <> progDesc "Set environment variable"
setEnv :: Options -> IO ()
-setEnv options = void $ prompt banner $ Env.engrave profile varName varValue
+setEnv options = void $ promptAnd engrave
where
- banner = engraveBanner profile varName Nothing varValue
-
varName = optName options
varValue = optValue options
@@ -61,6 +59,8 @@ setEnv options = void $ prompt banner $ Env.engrave profile varName varValue
| otherwise = Env.CurrentUser
skipPrompt = optYes options
- prompt
- | skipPrompt = const withoutPrompt
- | otherwise = withPrompt
+ promptAnd
+ | skipPrompt = withoutPrompt
+ | otherwise = withPrompt $ engraveMessage profile varName Nothing varValue
+
+ engrave = Env.engrave profile varName varValue