diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 03:28:51 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 03:28:51 +0300 |
commit | 54db9a94963826141c79ffe30df0453f85a117c8 (patch) | |
tree | 22190418728ed381c1c0c45c2d58c5acfda06423 /apps/UnsetEnv.hs | |
parent | reorder imports (diff) | |
download | windows-env-54db9a94963826141c79ffe30df0453f85a117c8.tar.gz windows-env-54db9a94963826141c79ffe30df0453f85a117c8.zip |
bugfix + refactoring
Diffstat (limited to 'apps/UnsetEnv.hs')
-rw-r--r-- | apps/UnsetEnv.hs | 19 |
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 |