mirror of
https://github.com/simonmichael/hledger.git
synced 2024-10-06 19:07:27 +03:00
imp: ui, web: use a pager to show command line help, like cli
This commit is contained in:
parent
c8440c6c3a
commit
847e443e6b
@ -61,6 +61,9 @@ main = withProgName "hledger-ui.log" $ do -- force Hledger.Utils.Debug.* to log
|
||||
dbg1IO "args" progArgs
|
||||
dbg1IO "debugLevel" debugLevel
|
||||
|
||||
-- try to encourage user's $PAGER to properly display ANSI (in command line help)
|
||||
when useColorOnStdout setupPager
|
||||
|
||||
opts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=iopts,rawopts_=rawopts}} <- getHledgerUIOpts
|
||||
-- when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts)
|
||||
|
||||
@ -68,7 +71,7 @@ main = withProgName "hledger-ui.log" $ do -- force Hledger.Utils.Debug.* to log
|
||||
let copts' = copts{inputopts_=iopts{forecast_=forecast_ iopts <|> Just nulldatespan}}
|
||||
|
||||
case True of
|
||||
_ | "help" `inRawOpts` rawopts -> putStr (showModeUsage uimode)
|
||||
_ | "help" `inRawOpts` rawopts -> pager (showModeUsage uimode)
|
||||
_ | "info" `inRawOpts` rawopts -> runInfoForTopic "hledger-ui" Nothing
|
||||
_ | "man" `inRawOpts` rawopts -> runManForTopic "hledger-ui" Nothing
|
||||
_ | "version" `inRawOpts` rawopts -> putStrLn prognameandversion
|
||||
|
@ -48,10 +48,13 @@ hledgerWebDev =
|
||||
-- Run normally.
|
||||
hledgerWebMain :: IO ()
|
||||
hledgerWebMain = do
|
||||
-- try to encourage user's $PAGER to properly display ANSI (in command line help)
|
||||
when useColorOnStdout setupPager
|
||||
|
||||
wopts@WebOpts{cliopts_=copts@CliOpts{debug_, rawopts_}} <- getHledgerWebOpts
|
||||
when (debug_ > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show wopts)
|
||||
if
|
||||
| "help" `inRawOpts` rawopts_ -> putStr (showModeUsage webmode) >> exitSuccess
|
||||
| "help" `inRawOpts` rawopts_ -> pager (showModeUsage webmode) >> exitSuccess
|
||||
| "info" `inRawOpts` rawopts_ -> runInfoForTopic "hledger-web" Nothing
|
||||
| "man" `inRawOpts` rawopts_ -> runManForTopic "hledger-web" Nothing
|
||||
| "version" `inRawOpts` rawopts_ -> putStrLn prognameandversion >> exitSuccess
|
||||
|
@ -98,7 +98,7 @@ mainmode addons = defMode {
|
||||
main :: IO ()
|
||||
main = do
|
||||
starttime <- getPOSIXTime
|
||||
-- if we will be showing ANSI, try to ensure user's $PAGER will display it properly
|
||||
-- try to encourage user's $PAGER to properly display ANSI
|
||||
when useColorOnStdout setupPager
|
||||
|
||||
-- Choose and run the appropriate internal or external command based
|
||||
|
Loading…
Reference in New Issue
Block a user