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/RemovePath.hs | |
parent | refactoring (diff) | |
download | windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.tar.gz windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.zip |
refactoring
Diffstat (limited to 'apps/RemovePath.hs')
-rw-r--r-- | apps/RemovePath.hs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs index 21b4ac6..a594ecd 100644 --- a/apps/RemovePath.hs +++ b/apps/RemovePath.hs @@ -6,7 +6,7 @@ module Main (main) where -import Control.Monad (when) +import Control.Monad (void, when) import Data.List ((\\)) import Data.Maybe (fromJust, isJust) @@ -14,11 +14,13 @@ import Options.Applicative import qualified Environment +import qualified Utils + data Options = Options - { optName :: String + { optName :: Environment.VarName , optYes :: Bool , optGlobal :: Bool - , optPaths :: [String] + , optPaths :: [Environment.VarValue] } deriving (Eq, Show) options = Options @@ -57,16 +59,17 @@ removePath options = do forAllUsers = optGlobal options - removePathFrom env = do - oldValue <- Environment.query env varName + removePathFrom profile = do + oldValue <- Environment.query profile varName when (isJust oldValue) $ do let oldPaths = Environment.pathSplit $ fromJust oldValue let newPaths = oldPaths \\ pathsToRemove when (length oldPaths /= length newPaths) $ do let newValue = Environment.pathJoin newPaths - engrave env newValue + let promptBanner = Utils.engraveBanner profile varName oldValue newValue + void $ prompt promptBanner $ Environment.engrave profile varName newValue skipPrompt = optYes options - engrave env 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 |