imp: cli: --color now also accepts y or n, like --pretty

This commit is contained in:
Simon Michael 2024-05-28 23:37:31 -10:00
parent a366f3aeaa
commit 1fe7e7af8c
2 changed files with 5 additions and 5 deletions

View File

@ -230,7 +230,7 @@ rawOptsToReportOpts d rawopts =
let formatstring = T.pack <$> maybestringopt "format" rawopts
querystring = map T.pack $ listofstringopt "args" rawopts -- doesn't handle an arg like "" right
pretty = fromMaybe False $ alwaysneveropt "pretty" rawopts
pretty = fromMaybe False $ ynopt "pretty" rawopts
format = case parseStringFormat <$> formatstring of
Nothing -> defaultBalanceLineFormat
@ -329,8 +329,8 @@ balancecalcopt =
balanceaccumopt :: RawOpts -> BalanceAccumulation
balanceaccumopt = fromMaybe PerPeriod . balanceAccumulationOverride
alwaysneveropt :: String -> RawOpts -> Maybe Bool
alwaysneveropt opt rawopts = case maybestringopt opt rawopts of
ynopt :: String -> RawOpts -> Maybe Bool
ynopt opt rawopts = case maybestringopt opt rawopts of
Just "always" -> Just True
Just "yes" -> Just True
Just "y" -> Just True

View File

@ -360,8 +360,8 @@ useColorOnHandle h = unsafePerformIO $ do
no_color <- isJust <$> lookupEnv "NO_COLOR"
supports_color <- hSupportsANSIColor h
let coloroption = colorOption
return $ coloroption `elem` ["always","yes"]
|| (coloroption `notElem` ["never","no"] && not no_color && supports_color)
return $ coloroption `elem` ["always","yes","y"]
|| (coloroption `notElem` ["never","no","n"] && not no_color && supports_color)
-- | Wrap a string in ANSI codes to set and reset foreground colour.
-- ColorIntensity is @Dull@ or @Vivid@ (ie normal and bold).