diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index a129084fb..90b3234df 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -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 _ -> "" diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index b482c24e9..bb54cf619 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -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"