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/UnsetEnv.hs | |
parent | refactoring (diff) | |
download | windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.tar.gz windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.zip |
refactoring
Diffstat (limited to 'apps/UnsetEnv.hs')
-rw-r--r-- | apps/UnsetEnv.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs index e4cbeac..b0ed96a 100644 --- a/apps/UnsetEnv.hs +++ b/apps/UnsetEnv.hs @@ -6,14 +6,18 @@ module Main (main) where +import Control.Monad (void) + import Options.Applicative import qualified Environment +import qualified Utils + data Options = Options { optYes :: Bool , optGlobal :: Bool - , optName :: String + , optName :: Environment.VarName } deriving (Eq, Show) options :: Parser Options @@ -39,16 +43,18 @@ main = execParser parser >>= unsetEnv fullDesc <> progDesc "Unset environment variable" unsetEnv :: Options -> IO () -unsetEnv options = wipe +unsetEnv options = void $ prompt confirmationBanner $ Environment.wipe profile varName where + confirmationBanner = Utils.wipeBanner profile varName + varName = optName options forAllUsers = optGlobal options - env = if forAllUsers + profile = if forAllUsers then Environment.AllUsers else Environment.CurrentUser skipPrompt = optYes options - wipe = if skipPrompt - then Environment.wipe env varName - else Environment.wipePrompt env varName >> return () + prompt = if skipPrompt + then const Utils.withoutPrompt + else Utils.withPrompt |