diff --git a/hledger-web/Hledger/Web/Options.hs b/hledger-web/Hledger/Web/Options.hs index 57d897b26..eaa3aca2c 100644 --- a/hledger-web/Hledger/Web/Options.hs +++ b/hledger-web/Hledger/Web/Options.hs @@ -66,8 +66,8 @@ defwebopts = WebOpts -- instance Default WebOpts where def = defwebopts -toWebOpts :: RawOpts -> IO WebOpts -toWebOpts rawopts = do +rawOptsToWebOpts :: RawOpts -> IO WebOpts +rawOptsToWebOpts rawopts = checkWebOpts <$> do cliopts <- rawOptsToCliOpts rawopts let p = fromMaybe defport $ maybeintopt "port" rawopts return defwebopts { @@ -80,11 +80,9 @@ toWebOpts rawopts = do where stripTrailingSlash = reverse . dropWhile (=='/') . reverse -- yesod don't like it -checkWebOpts :: WebOpts -> IO WebOpts -checkWebOpts opts = do - _ <- checkCliOpts $ cliopts_ opts - return opts +checkWebOpts :: WebOpts -> WebOpts +checkWebOpts = id getHledgerWebOpts :: IO WebOpts -getHledgerWebOpts = processArgs webmode >>= return . decodeRawOpts >>= toWebOpts >>= checkWebOpts +getHledgerWebOpts = processArgs webmode >>= return . decodeRawOpts >>= rawOptsToWebOpts diff --git a/hledger/Hledger/Cli/Main.hs b/hledger/Hledger/Cli/Main.hs index b3667f0b7..aa0ca42a5 100644 --- a/hledger/Hledger/Cli/Main.hs +++ b/hledger/Hledger/Cli/Main.hs @@ -144,7 +144,7 @@ argsToCliOpts args addons = do args' = moveFlagsAfterCommand args cmdargsopts = processValue (mainmode addons) args' cmdargsopts' = decodeRawOpts cmdargsopts - rawOptsToCliOpts cmdargsopts' >>= checkCliOpts + rawOptsToCliOpts cmdargsopts' -- | A hacky workaround for cmdargs not accepting flags before the -- subcommand name: try to detect and move such flags after the