summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors/Weather.hs
diff options
context:
space:
mode:
authorslotThe <soliditsallgood@tuta.io>2020-01-04 21:20:56 +0100
committerjao <jao@gnu.org>2020-01-04 21:21:40 +0000
commit940be3bb32ed1f11c46ede98d51516998b17e128 (patch)
tree6d0c942c10efc64514dd419f746f631aec19c935 /src/Xmobar/Plugins/Monitors/Weather.hs
parent2ec513d2e193998958ad5bf4a5f7280f595792e9 (diff)
downloadxmobar-940be3bb32ed1f11c46ede98d51516998b17e128.tar.gz
xmobar-940be3bb32ed1f11c46ede98d51516998b17e128.tar.bz2
Replace parseOpts with a generic function
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Weather.hs')
-rw-r--r--src/Xmobar/Plugins/Monitors/Weather.hs16
1 files changed, 2 insertions, 14 deletions
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
"<station>: <tempC>C, rh <rh>% (<hour>)" -- 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