diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-10-05 10:30:29 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-10-05 10:46:55 +0200 |
commit | 6b76050f758917cf3552c20f99a4bfedd66049f2 (patch) | |
tree | 465be9bfbacacb40b1454b53fcd084e19397aca4 /app/Issue.hs | |
parent | 16da8a1ea6187f4bd5ef176f2aed64403b111c8c (diff) |
show single issue by id only
Diffstat (limited to 'app/Issue.hs')
-rw-r--r-- | app/Issue.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Issue.hs b/app/Issue.hs index 07bddee..d163df7 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -3,17 +3,19 @@ {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} -module Issue (Issue (..), fromMatch) where +module Issue (Issue (..), fromMatch, id) where +import Data.List (find) import Data.Text (Text) import Data.Text qualified as T -import Issue.Tag (Tag) +import Issue.Tag (Tag (..)) import Issue.Tag qualified as I import Issue.Text qualified as I import TreeGrepper.Match (Match (..)) import TreeGrepper.Match qualified as G import TreeGrepper.Result (Result (..)) import TreeGrepper.Result qualified as G +import Prelude hiding (id) data Issue = Issue { title :: Text, @@ -23,6 +25,14 @@ data Issue = Issue tags :: [Tag], internalTags :: [Tag] } + deriving (Show) + +id :: Issue -> Maybe String +id issue = + (\(Tag _ v) -> T.unpack v) + <$> ( find (\(Tag k _) -> k == "id") $ + issue.tags ++ issue.internalTags + ) fromMatch :: G.Result -> G.Match -> Maybe Issue fromMatch result match = |