aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/AddPath.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/AddPath.hs
parentREADME update (diff)
downloadwindows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.tar.gz
windows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.zip
fix compiler warnings + refactoring
Diffstat (limited to 'apps/AddPath.hs')
-rw-r--r--apps/AddPath.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs
index 343207c..1f80f70 100644
--- a/apps/AddPath.hs
+++ b/apps/AddPath.hs
@@ -13,8 +13,8 @@ import Data.Maybe (fromMaybe)
import Options.Applicative
import qualified Windows.Environment as Env
-import Banner
import Prompt
+import PromptMessage
data Options = Options
{ optName :: Env.VarName
@@ -23,8 +23,8 @@ data Options = Options
, optPaths :: [Env.VarValue]
} deriving (Eq, Show)
-options :: Parser Options
-options = Options
+optionParser :: Parser Options
+optionParser = Options
<$> optNameDesc
<*> optYesDesc
<*> optGlobalDesc
@@ -46,7 +46,7 @@ options = Options
main :: IO ()
main = execParser parser >>= addPath
where
- parser = info (helper <*> options) $
+ parser = info (helper <*> optionParser) $
fullDesc <> progDesc "Add directories to your PATH"
addPath :: Options -> IO ()
@@ -56,8 +56,11 @@ addPath options = do
let newPaths = union oldPaths pathsToAdd
when (length oldPaths /= length newPaths) $ do
let newValue = Env.pathJoin newPaths
- let banner = engraveBanner profile varName oldValue newValue
- void $ 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
+ void $ promptAnd engrave
where
varName = optName options
pathsToAdd = optPaths options
@@ -68,6 +71,3 @@ addPath options = do
| otherwise = Env.CurrentUser
skipPrompt = optYes options
- prompt
- | skipPrompt = const withoutPrompt
- | otherwise = withPrompt