diff options
Diffstat (limited to '')
-rw-r--r-- | apps/AddPath.hs | 18 |
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 |