From 940be3bb32ed1f11c46ede98d51516998b17e128 Mon Sep 17 00:00:00 2001 From: slotThe Date: Sat, 4 Jan 2020 21:20:56 +0100 Subject: Replace parseOpts with a generic function --- src/Xmobar/Plugins/Monitors/Weather.hs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/Xmobar/Plugins/Monitors/Weather.hs') diff --git a/src/Xmobar/Plugins/Monitors/Weather.hs b/src/Xmobar/Plugins/Monitors/Weather.hs index b2a3dd4..07d8cc4 100644 --- a/src/Xmobar/Plugins/Monitors/Weather.hs +++ b/src/Xmobar/Plugins/Monitors/Weather.hs @@ -26,12 +26,7 @@ import qualified Data.ByteString.Lazy.Char8 as B import Data.Char (toLower) import Text.ParserCombinators.Parsec -import System.Console.GetOpt - ( ArgDescr(ReqArg) - , ArgOrder(Permute) - , OptDescr(Option) - , getOpt - ) +import System.Console.GetOpt (ArgDescr(ReqArg), OptDescr(Option)) -- | Options the user may specify. @@ -51,13 +46,6 @@ options = [ Option "w" ["weathers"] (ReqArg (\s o -> o { weatherString = s }) "") "" ] --- | Try to parse arguments from the config file and apply them. -parseOpts :: [String] -> IO WeatherOpts -parseOpts argv = - case getOpt Permute options argv of - (o, _, [] ) -> return $ foldr id defaultOpts o - (_, _, errs) -> ioError . userError $ concat errs - weatherConfig :: IO MConfig weatherConfig = mkMConfig ": C, rh % ()" -- template @@ -260,7 +248,7 @@ runWeather = runWeather' [] runWeather' :: [(String, String)] -> [String] -> Monitor String runWeather' sks args = do d <- io $ getData $ head args - o <- io $ parseOpts args + o <- io $ parseOptsWith options defaultOpts args i <- io $ runP parseData d formatWeather o sks i -- cgit v1.2.3