diff options
Diffstat (limited to '')
-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 |