dev: cln: drop Hledger.Data.RawOptions.inRawOpts
This commit is contained in:
parent
a1da8f2899
commit
147d49c66c
@ -13,7 +13,6 @@ module Hledger.Data.RawOptions (
|
|||||||
setboolopt,
|
setboolopt,
|
||||||
unsetboolopt,
|
unsetboolopt,
|
||||||
appendopts,
|
appendopts,
|
||||||
inRawOpts,
|
|
||||||
boolopt,
|
boolopt,
|
||||||
choiceopt,
|
choiceopt,
|
||||||
collectopts,
|
collectopts,
|
||||||
@ -56,12 +55,9 @@ unsetboolopt name = overRawOpts (filter ((/=name).fst))
|
|||||||
appendopts :: [(String,String)] -> RawOpts -> RawOpts
|
appendopts :: [(String,String)] -> RawOpts -> RawOpts
|
||||||
appendopts new = overRawOpts (++new)
|
appendopts new = overRawOpts (++new)
|
||||||
|
|
||||||
-- | Is the named option present ?
|
-- | Is the named flag present ?
|
||||||
inRawOpts :: String -> RawOpts -> Bool
|
|
||||||
inRawOpts name = isJust . lookup name . unRawOpts
|
|
||||||
|
|
||||||
boolopt :: String -> RawOpts -> Bool
|
boolopt :: String -> RawOpts -> Bool
|
||||||
boolopt = inRawOpts
|
boolopt name = isJust . lookup name . unRawOpts
|
||||||
|
|
||||||
-- | From a list of RawOpts, get the last one (ie the right-most on the command line)
|
-- | From a list of RawOpts, get the last one (ie the right-most on the command line)
|
||||||
-- for which the given predicate returns a Just value.
|
-- for which the given predicate returns a Just value.
|
||||||
|
|||||||
@ -72,11 +72,11 @@ main = withProgName "hledger-ui.log" $ do -- force Hledger.Utils.Debug.* to log
|
|||||||
let copts' = copts{inputopts_=iopts{forecast_=forecast_ iopts <|> Just nulldatespan}}
|
let copts' = copts{inputopts_=iopts{forecast_=forecast_ iopts <|> Just nulldatespan}}
|
||||||
|
|
||||||
case True of
|
case True of
|
||||||
_ | "help" `inRawOpts` rawopts -> pager (showModeUsage uimode)
|
_ | boolopt "help" rawopts -> pager (showModeUsage uimode)
|
||||||
_ | "info" `inRawOpts` rawopts -> runInfoForTopic "hledger-ui" Nothing
|
_ | boolopt "info" rawopts -> runInfoForTopic "hledger-ui" Nothing
|
||||||
_ | "man" `inRawOpts` rawopts -> runManForTopic "hledger-ui" Nothing
|
_ | boolopt "man" rawopts -> runManForTopic "hledger-ui" Nothing
|
||||||
_ | "version" `inRawOpts` rawopts -> putStrLn prognameandversion
|
_ | boolopt "version" rawopts -> putStrLn prognameandversion
|
||||||
-- _ | "binary-filename" `inRawOpts` rawopts -> putStrLn (binaryfilename progname)
|
-- _ | boolopt "binary-filename" rawopts -> putStrLn (binaryfilename progname)
|
||||||
_ -> withJournalDo copts' (runBrickUi opts)
|
_ -> withJournalDo copts' (runBrickUi opts)
|
||||||
|
|
||||||
runBrickUi :: UIOpts -> Journal -> IO ()
|
runBrickUi :: UIOpts -> Journal -> IO ()
|
||||||
|
|||||||
@ -54,12 +54,12 @@ hledgerWebMain = do
|
|||||||
wopts@WebOpts{cliopts_=copts@CliOpts{debug_, rawopts_}} <- getHledgerWebOpts
|
wopts@WebOpts{cliopts_=copts@CliOpts{debug_, rawopts_}} <- getHledgerWebOpts
|
||||||
when (debug_ > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show wopts)
|
when (debug_ > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show wopts)
|
||||||
if
|
if
|
||||||
| "help" `inRawOpts` rawopts_ -> pager (showModeUsage webmode) >> exitSuccess
|
| boolopt "help" rawopts_ -> pager (showModeUsage webmode) >> exitSuccess
|
||||||
| "info" `inRawOpts` rawopts_ -> runInfoForTopic "hledger-web" Nothing
|
| boolopt "info" rawopts_ -> runInfoForTopic "hledger-web" Nothing
|
||||||
| "man" `inRawOpts` rawopts_ -> runManForTopic "hledger-web" Nothing
|
| boolopt "man" rawopts_ -> runManForTopic "hledger-web" Nothing
|
||||||
| "version" `inRawOpts` rawopts_ -> putStrLn prognameandversion >> exitSuccess
|
| boolopt "version" rawopts_ -> putStrLn prognameandversion >> exitSuccess
|
||||||
-- "binary-filename" `inRawOpts` rawopts_ -> putStrLn (binaryfilename progname)
|
-- boolopt "binary-filename" rawopts_ -> putStrLn (binaryfilename progname)
|
||||||
| "test" `inRawOpts` rawopts_ -> do
|
| boolopt "test" rawopts_ -> do
|
||||||
-- remove --test and --, leaving other args for hspec
|
-- remove --test and --, leaving other args for hspec
|
||||||
(`withArgs` hledgerWebTest) . filter (`notElem` ["--test","--"]) =<< getArgs
|
(`withArgs` hledgerWebTest) . filter (`notElem` ["--test","--"]) =<< getArgs
|
||||||
| otherwise -> withJournalDo copts (web wopts)
|
| otherwise -> withJournalDo copts (web wopts)
|
||||||
|
|||||||
@ -575,8 +575,8 @@ getHledgerCliOpts' mode' args0 = do
|
|||||||
let rawopts = either usageError id $ process mode' args0
|
let rawopts = either usageError id $ process mode' args0
|
||||||
opts <- rawOptsToCliOpts rawopts
|
opts <- rawOptsToCliOpts rawopts
|
||||||
debugArgs args0 opts
|
debugArgs args0 opts
|
||||||
when ("help" `inRawOpts` rawopts_ opts) $ putStr shorthelp >> exitSuccess
|
when (boolopt "help" $ rawopts_ opts) $ putStr shorthelp >> exitSuccess
|
||||||
-- when ("help" `inRawOpts` rawopts_ opts) $ putStr longhelp >> exitSuccess
|
-- when (boolopt "help" $ rawopts_ opts) $ putStr longhelp >> exitSuccess
|
||||||
return opts
|
return opts
|
||||||
where
|
where
|
||||||
longhelp = showModeUsage mode'
|
longhelp = showModeUsage mode'
|
||||||
|
|||||||
@ -174,7 +174,7 @@ main = do
|
|||||||
| not (isExternalCommand || hasHelpFlag args || hasInfoFlag args || hasManFlag args)
|
| not (isExternalCommand || hasHelpFlag args || hasInfoFlag args || hasManFlag args)
|
||||||
&& (hasVersion args) -- || (hasVersion argsaftercmd && isInternalCommand))
|
&& (hasVersion args) -- || (hasVersion argsaftercmd && isInternalCommand))
|
||||||
= putStrLn prognameandversion
|
= putStrLn prognameandversion
|
||||||
-- \| (null externalcmd) && "binary-filename" `inRawOpts` rawopts = putStrLn $ binaryfilename progname
|
-- \| (null externalcmd) && boolopt "binary-filename" rawopts = putStrLn $ binaryfilename progname
|
||||||
-- \| "--browse-args" `elem` args = System.Console.CmdArgs.Helper.execute "cmdargs-browser" mainmode' args >>= (putStr . show)
|
-- \| "--browse-args" `elem` args = System.Console.CmdArgs.Helper.execute "cmdargs-browser" mainmode' args >>= (putStr . show)
|
||||||
| isNullCommand = dbgIO "" "no command, showing commands list" >> printCommandsList prognameandversion addons
|
| isNullCommand = dbgIO "" "no command, showing commands list" >> printCommandsList prognameandversion addons
|
||||||
| isBadCommand = badCommandError
|
| isBadCommand = badCommandError
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user