diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-18 00:09:44 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-18 00:09:44 +0300 |
commit | 14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4 (patch) | |
tree | 60daf05b8eafaec8ae4d4d90ac6cc59b4a1af22a /apps/SetEnv.hs | |
parent | refactoring (diff) | |
download | windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.tar.gz windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.zip |
refactoring
Diffstat (limited to '')
-rw-r--r-- | apps/SetEnv.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/SetEnv.hs b/apps/SetEnv.hs index 3b88e7c..0b95176 100644 --- a/apps/SetEnv.hs +++ b/apps/SetEnv.hs @@ -6,15 +6,19 @@ module Main (main) where +import Control.Monad (void) + import Options.Applicative hiding (value) import qualified Environment +import qualified Utils + data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: String - , optValue :: String + , optName :: Environment.VarName + , optValue :: Environment.VarValue } deriving (Eq, Show) options :: Parser Options @@ -44,17 +48,19 @@ main = execParser parser >>= setEnv fullDesc <> progDesc "Set environment variable" setEnv :: Options -> IO () -setEnv options = engrave varValue +setEnv options = void $ prompt confirmationBanner $ Environment.engrave profile varName varValue where + confirmationBanner = Utils.engraveBanner profile varName Nothing varValue + varName = optName options varValue = optValue options forAllUsers = optGlobal options - env = if forAllUsers + profile = if forAllUsers then Environment.AllUsers else Environment.CurrentUser skipPrompt = optYes options - engrave value = if skipPrompt - then Environment.engrave env varName value - else Environment.engravePrompt env varName value >> return () + prompt = if skipPrompt + then const Utils.withoutPrompt + else Utils.withPrompt |