aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/FixNtSymbolPath.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/FixNtSymbolPath.hs
parentREADME update (diff)
downloadwindows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.tar.gz
windows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.zip
fix compiler warnings + refactoring
Diffstat (limited to 'apps/FixNtSymbolPath.hs')
-rw-r--r--apps/FixNtSymbolPath.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs
index 219ceb2..a1b1e9e 100644
--- a/apps/FixNtSymbolPath.hs
+++ b/apps/FixNtSymbolPath.hs
@@ -15,16 +15,16 @@ import System.FilePath (combine)
import Options.Applicative
import qualified Windows.Environment as Env
-import Banner
import Prompt
+import PromptMessage
data Options = Options
{ optYes :: Bool
, optGlobal :: Bool
} deriving (Eq, Show)
-options :: Parser Options
-options = Options
+optionParser :: Parser Options
+optionParser = Options
<$> optYesDesc
<*> optGlobalDesc
where
@@ -73,8 +73,11 @@ fixNtSymbolPath options = do
let newPaths = union oldPaths $ dirPaths remoteDirs
when (length oldPaths /= length newPaths) $ do
let newValue = Env.pathJoin newPaths
- let banner = engraveBanner profile varName oldValue newValue
- agreed <- prompt banner $ Env.engrave profile varName newValue
+ let promptAnd = if skipPrompt
+ then withoutPrompt
+ else withPrompt $ engraveMessage profile varName oldValue newValue
+ let engrave = Env.engrave profile varName newValue
+ agreed <- promptAnd engrave
when agreed $
createDirs localDirs
where
@@ -86,12 +89,9 @@ fixNtSymbolPath options = do
| otherwise = Env.CurrentUser
skipPrompt = optYes options
- prompt
- | skipPrompt = const withoutPrompt
- | otherwise = withPrompt
main :: IO ()
main = execParser parser >>= fixNtSymbolPath
where
- parser = info (helper <*> options) $
+ parser = info (helper <*> optionParser) $
fullDesc <> progDesc "Set up your _NT_SYMBOL_PATH"