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/FixNtSymbolPath.hs | |
parent | refactoring (diff) | |
download | windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.tar.gz windows-env-14d1ee026b9f2dded1eb1adc51e50f6b779b4aa4.zip |
refactoring
Diffstat (limited to '')
-rw-r--r-- | apps/FixNtSymbolPath.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs index 14d0861..3788381 100644 --- a/apps/FixNtSymbolPath.hs +++ b/apps/FixNtSymbolPath.hs @@ -16,6 +16,8 @@ import Options.Applicative import qualified Environment +import qualified Utils + data Options = Options { optYes :: Bool , optGlobal :: Bool @@ -64,30 +66,29 @@ getLocalDirs = do fixNtSymbolPath :: Options -> IO () fixNtSymbolPath options = do - oldValue <- query + oldValue <- Environment.query profile varName let oldPaths = Environment.pathSplit $ fromMaybe "" oldValue localDirs <- getLocalDirs let remoteDirs = toRemoteDirs localDirs let newPaths = union oldPaths $ dirPaths remoteDirs when (length oldPaths /= length newPaths) $ do let newValue = Environment.pathJoin newPaths - confirmed <- engrave newValue + let promptBanner = Utils.engraveBanner profile varName oldValue newValue + confirmed <- prompt promptBanner $ Environment.engrave profile varName newValue when confirmed $ createDirs localDirs where varName = "_NT_SYMBOL_PATH" forAllUsers = optGlobal options - env = if forAllUsers + profile = if forAllUsers then Environment.AllUsers else Environment.CurrentUser - query = Environment.query env varName - skipPrompt = optYes options - engrave value = if skipPrompt - then Environment.engrave env varName value >> return True - else Environment.engravePrompt env varName value + prompt = if skipPrompt + then const Utils.withoutPrompt + else Utils.withPrompt main :: IO () main = execParser parser >>= fixNtSymbolPath |