aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/UnsetEnv.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
commit54db9a94963826141c79ffe30df0453f85a117c8 (patch)
tree22190418728ed381c1c0c45c2d58c5acfda06423 /apps/UnsetEnv.hs
parentreorder imports (diff)
downloadwindows-env-54db9a94963826141c79ffe30df0453f85a117c8.tar.gz
windows-env-54db9a94963826141c79ffe30df0453f85a117c8.zip
bugfix + refactoring
Diffstat (limited to 'apps/UnsetEnv.hs')
-rw-r--r--apps/UnsetEnv.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/apps/UnsetEnv.hs b/apps/UnsetEnv.hs
index 6fa2f2c..51f71e8 100644
--- a/apps/UnsetEnv.hs
+++ b/apps/UnsetEnv.hs
@@ -11,19 +11,19 @@ import Options.Applicative
import qualified Environment
data Options = Options
- { global :: Bool
- , name :: String
+ { optGlobal :: Bool
+ , optName :: String
} deriving (Eq, Show)
options :: Parser Options
options = Options
- <$> globalOption
- <*> nameArg
+ <$> optGlobalDesc
+ <*> optNameDesc
where
- globalOption = switch $
+ optGlobalDesc = switch $
long "global" <> short 'g' <>
help "Whether to unset for all users"
- nameArg = argument str $
+ optNameDesc = argument str $
metavar "NAME" <>
help "Variable name"
@@ -34,7 +34,8 @@ main = execParser parser >>= unsetEnv
fullDesc <> progDesc "Unset environment variables"
unsetEnv :: Options -> IO ()
-unsetEnv options = Environment.wipeWithPrompt env $ name options
+unsetEnv options = Environment.wipeWithPrompt env varName
where
- env | global options = Environment.AllUsers
- | otherwise = Environment.CurrentUser
+ env | optGlobal options = Environment.AllUsers
+ | otherwise = Environment.CurrentUser
+ varName = optName options