mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-24 19:02:46 +03:00
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
|
||||
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
|
||||
|
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user