aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/UnsetEnv.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/UnsetEnv.hs
parentREADME update (diff)
downloadwindows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.tar.gz
windows-env-62f1e6b804a940506eff5f3f924d2d000e16119d.zip
fix compiler warnings + refactoring
Diffstat (limited to 'apps/UnsetEnv.hs')
-rw-r--r--apps/UnsetEnv.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs
index eebef00..767c681 100644
--- a/apps/UnsetEnv.hs
+++ b/apps/UnsetEnv.hs
@@ -11,8 +11,8 @@ import Control.Monad (void)
import Options.Applicative
import qualified Windows.Environment as Env
-import Banner
import Prompt
+import PromptMessage
data Options = Options
{ optYes :: Bool
@@ -20,13 +20,13 @@ data Options = Options
, optName :: Env.VarName
} deriving (Eq, Show)
-options :: Parser Options
-options = Options
- <$> optYes
+optionParser :: Parser Options
+optionParser = Options
+ <$> optYesDesc
<*> optGlobalDesc
<*> optNameDesc
where
- optYes = switch $
+ optYesDesc = switch $
long "yes" <> short 'y' <>
help "Skip confirmation prompt"
optGlobalDesc = switch $
@@ -39,14 +39,12 @@ options = Options
main :: IO ()
main = execParser parser >>= unsetEnv
where
- parser = info (helper <*> options) $
+ parser = info (helper <*> optionParser) $
fullDesc <> progDesc "Unset environment variable"
unsetEnv :: Options -> IO ()
-unsetEnv options = void $ prompt banner $ Env.wipe profile varName
+unsetEnv options = void $ promptAnd wipe
where
- banner = wipeBanner profile varName
-
varName = optName options
forAllUsers = optGlobal options
@@ -55,6 +53,8 @@ unsetEnv options = void $ prompt banner $ Env.wipe profile varName
| otherwise = Env.CurrentUser
skipPrompt = optYes options
- prompt
- | skipPrompt = const withoutPrompt
- | otherwise = withPrompt
+ promptAnd
+ | skipPrompt = withoutPrompt
+ | otherwise = withPrompt $ wipeMessage profile varName
+
+ wipe = Env.wipe profile varName