;lib: comments

This commit is contained in:
Simon Michael 2021-04-17 16:06:20 -10:00
parent 1afb84c95d
commit fe846a0c7f
2 changed files with 8 additions and 1 deletions

View File

@ -208,20 +208,25 @@ useColorOnHandle h = unsafePerformIO $ do
-- (When running code in GHCI, this module must be reloaded to see a change.)
-- {-# OPTIONS_GHC -fno-cse #-}
-- {-# NOINLINE colorOption #-}
-- Keep synced with color/colour flag definition in hledger:CliOptions
colorOption :: String
colorOption =
-- similar to debugLevel
let args = unsafePerformIO getArgs in
case snd $ break (=="--color") args of
-- --color ARG
"--color":v:_ -> v
_ ->
case take 1 $ filter ("--color=" `isPrefixOf`) args of
-- --color=ARG
['-':'-':'c':'o':'l':'o':'r':'=':v] -> v
_ ->
case snd $ break (=="--colour") args of
-- --colour ARG
"--colour":v:_ -> v
_ ->
case take 1 $ filter ("--colour=" `isPrefixOf`) args of
-- --colour=ARG
['-':'-':'c':'o':'l':'o':'u':'r':'=':v] -> v
_ -> ""

View File

@ -190,7 +190,8 @@ reportflags = [
])
-- general output-related
-- This has special support in hledger-lib:colorOption, keep synced
,flagReq ["color","colour"] (\s opts -> Right $ setopt "color" s opts) "WHEN"
(unlines
["Should color-supporting commands use ANSI color codes in text output."
@ -228,6 +229,7 @@ outputFormatFlag fmts = flagReq
["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT"
("select the output format. Supported formats:\n" ++ intercalate ", " fmts ++ ".")
-- This has special support in hledger-lib:outputFileOption, keep synced
outputFileFlag :: Flag RawOpts
outputFileFlag = flagReq
["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE"