diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-11-09 15:43:28 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-09 15:47:28 +0100 |
commit | a37d3605e40b5c9c125568045e0fb99e9796fe49 (patch) | |
tree | d2a16285cd3724580e2db5f5d04b8f217b4ac873 /app/Issue | |
parent | 12511580c732895e8c5d045e18803a766ed733b8 (diff) |
group-by -> group
Diffstat (limited to 'app/Issue')
-rw-r--r-- | app/Issue/Group.hs (renamed from app/Issue/GroupBy.hs) | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/app/Issue/GroupBy.hs b/app/Issue/Group.hs index 18859f2..69caf20 100644 --- a/app/Issue/GroupBy.hs +++ b/app/Issue/Group.hs @@ -1,5 +1,5 @@ -module Issue.GroupBy - ( groupByArg, +module Issue.Group + ( groupArg, groupIssuesBy, ) where @@ -13,12 +13,12 @@ import Issue.Tag (Tag (..)) import Issue.Tag qualified as I import Options.Applicative qualified as O -groupByArg :: O.Parser (Maybe T.Text) -groupByArg = +groupArg :: O.Parser (Maybe T.Text) +groupArg = O.optional ( O.option (O.maybeReader (parse . T.pack)) - ( O.long "group-by" + ( O.long "group" <> O.metavar "TAG" <> O.help "Group selected issues." ) @@ -29,17 +29,19 @@ groupByArg = | otherwise = Nothing groupIssuesBy :: T.Text -> [Issue] -> Map T.Text [Issue] -groupIssuesBy groupBy issues = +groupIssuesBy group issues = foldl ( \collected issue -> foldl (flip $ M.alter (Just . maybe [issue] (issue :))) collected - (groupsOfIssue groupBy issue) + (groupsOfIssue group issue) ) M.empty issues - where - groupsOfIssue group issue = - mapMaybe I.tagValue $ - filter (\(Tag key _) -> key == group) (issue.tags ++ issue.internalTags) + +groupsOfIssue :: T.Text -> Issue -> [T.Text] +groupsOfIssue group issue = + mapMaybe I.tagValue + . filter (\(Tag key _) -> key == group) + $ issue.tags ++ issue.internalTags |