imp: cli: fix help headings highlighting

This commit is contained in:
Simon Michael 2024-05-29 10:29:26 -10:00
parent 56bc34f1a2
commit c35eed5506

View File

@ -466,18 +466,20 @@ highlightHelp
| not useColorOnStdout = id | not useColorOnStdout = id
| otherwise = unlines . zipWith (curry f) [1..] . lines | otherwise = unlines . zipWith (curry f) [1..] . lines
where where
f (n,s) f (n,l)
| n==1 = bold s | n==1 = bold l
| any (`isPrefixOf` s) [ -- keep synced with Hledger.Cli.mainmode | isHelpHeading l = bold l
"General input flags" | otherwise = l
,"General reporting flags" -- keep synced with Hledger.Cli.mainmode:
,"General help flags" isHelpHeading l = isAlphaNum (headDef ' ' l) && (lastDef ' ' l == ':')
,"Flags" -- any s (`isPrefixOf` s) [
,"General flags" -- "General input flags"
,"Examples" -- ,"General reporting flags"
] = bold s -- ,"General help flags"
| otherwise = s -- ,"Flags"
-- ,"General flags"
-- ,"Examples"
-- ]
-- | Get the most appropriate documentation topic for a mode. -- | Get the most appropriate documentation topic for a mode.
-- Currently, that is either the hledger, hledger-ui or hledger-web -- Currently, that is either the hledger, hledger-ui or hledger-web
-- manual. -- manual.