imp: cli: --color now also accepts y or n, like --pretty
This commit is contained in:
parent
a366f3aeaa
commit
1fe7e7af8c
@ -230,7 +230,7 @@ rawOptsToReportOpts d rawopts =
|
|||||||
|
|
||||||
let formatstring = T.pack <$> maybestringopt "format" rawopts
|
let formatstring = T.pack <$> maybestringopt "format" rawopts
|
||||||
querystring = map T.pack $ listofstringopt "args" rawopts -- doesn't handle an arg like "" right
|
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
|
format = case parseStringFormat <$> formatstring of
|
||||||
Nothing -> defaultBalanceLineFormat
|
Nothing -> defaultBalanceLineFormat
|
||||||
@ -329,8 +329,8 @@ balancecalcopt =
|
|||||||
balanceaccumopt :: RawOpts -> BalanceAccumulation
|
balanceaccumopt :: RawOpts -> BalanceAccumulation
|
||||||
balanceaccumopt = fromMaybe PerPeriod . balanceAccumulationOverride
|
balanceaccumopt = fromMaybe PerPeriod . balanceAccumulationOverride
|
||||||
|
|
||||||
alwaysneveropt :: String -> RawOpts -> Maybe Bool
|
ynopt :: String -> RawOpts -> Maybe Bool
|
||||||
alwaysneveropt opt rawopts = case maybestringopt opt rawopts of
|
ynopt opt rawopts = case maybestringopt opt rawopts of
|
||||||
Just "always" -> Just True
|
Just "always" -> Just True
|
||||||
Just "yes" -> Just True
|
Just "yes" -> Just True
|
||||||
Just "y" -> Just True
|
Just "y" -> Just True
|
||||||
|
|||||||
@ -360,8 +360,8 @@ useColorOnHandle h = unsafePerformIO $ do
|
|||||||
no_color <- isJust <$> lookupEnv "NO_COLOR"
|
no_color <- isJust <$> lookupEnv "NO_COLOR"
|
||||||
supports_color <- hSupportsANSIColor h
|
supports_color <- hSupportsANSIColor h
|
||||||
let coloroption = colorOption
|
let coloroption = colorOption
|
||||||
return $ coloroption `elem` ["always","yes"]
|
return $ coloroption `elem` ["always","yes","y"]
|
||||||
|| (coloroption `notElem` ["never","no"] && not no_color && supports_color)
|
|| (coloroption `notElem` ["never","no","n"] && not no_color && supports_color)
|
||||||
|
|
||||||
-- | Wrap a string in ANSI codes to set and reset foreground colour.
|
-- | Wrap a string in ANSI codes to set and reset foreground colour.
|
||||||
-- ColorIntensity is @Dull@ or @Vivid@ (ie normal and bold).
|
-- ColorIntensity is @Dull@ or @Vivid@ (ie normal and bold).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user