From 2d47e950f2c66df89e5aec14d2be15f96e7c5716 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 9 Nov 2023 15:48:21 +0100 Subject: improve grouped list styling --- app/Main.hs | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index d6a263a..1016b77 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -586,30 +586,48 @@ main :: IO () main = do settings <- readSettings O.execParser (O.info (options <**> O.helper) O.idm) >>= \case - Options {colorize, noPager, width, command = List {sort, filters, files, group = Just group}} -> do + Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Just group}} -> do let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files ungroupedIssues <- applySorts sort . applyFilters filters . filter withinPath . fst <$> getHistory let groupedIssues = I.groupIssuesBy group ungroupedIssues putDoc colorize noPager width . P.vsep . intersperse ("" :: P.Doc ann) - $ map + $ concatMap ( \(name, issues) -> - P.vsep $ - ( P.annotate P.bold . P.annotate (P.color P.Yellow) $ - ( ( P.annotate P.bold $ - (("@" :: P.Doc ann) <> P.pretty group) <+> P.pretty name - ) - <+> ("(" :: P.Doc ann) - <> P.pretty (length issues) - <> (")" :: P.Doc ann) - ) - ) - : map - ( \issue -> - P.indent 4 $ P.pretty issue.title + ( P.annotate P.underlined $ + ( ( (("@" :: P.Doc ann) <> P.pretty group) <+> P.pretty name ) - issues + <+> ("(" :: P.Doc ann) + <> P.pretty (length issues) + <> (")" :: P.Doc ann) + ) + ) + : map + (P.indent 4) + ( map + ( \issue -> + let title = map (P.annotate P.bold . P.pretty) (T.words issue.title) + tags = prettyTags (issue.tags ++ if internalTags then issue.internalTags else []) + openedBy = + fromProvenance $ + P.annotate (P.color P.Black) . ("by" <+>) . P.pretty . (.first.author.name) + openedOn = + fromProvenance $ + P.annotate (P.color P.Black) . ("on" <+>) . P.pretty . show . utctDay . (.first.date) + fromProvenance = flip fmap issue.provenance + in P.nest 4 $ + P.fillSep + ( concat $ + [ title, + tags, + maybeToList openedOn, + maybeToList openedBy + ] + ) + ) + issues + ) ) (M.toList groupedIssues) Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Nothing}} -> do -- cgit v1.2.3