From 2b04b7644894e93c221f8c780e10812539a6e4e7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 13 Apr 2021 14:06:02 -1000 Subject: [PATCH] lib: debug output now respects --color/NO_COLOR/ANSI support Debug output now selects color or monochrome in the same way as normal output. --- hledger-lib/Hledger/Utils/Debug.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index 7d08b6dac..fe9aa0f8e 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -116,12 +116,14 @@ import System.Console.ANSI (hSupportsANSIColor) import System.IO (stdout) prettyopts = - defaultOutputOptionsDarkBg - -- defaultOutputOptionsLightBg - -- defaultOutputOptionsNoColor + baseopts { outputOptionsIndentAmount=2 , outputOptionsCompact=True } + where + baseopts + | useColor = defaultOutputOptionsDarkBg -- defaultOutputOptionsLightBg + | otherwise = defaultOutputOptionsNoColor -- | Pretty print. Generic alias for pretty-simple's pPrint. pprint :: Show a => a -> IO ()