diff options
Diffstat (limited to 'app/IssueEvent.hs')
-rw-r--r-- | app/IssueEvent.hs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/IssueEvent.hs b/app/IssueEvent.hs new file mode 100644 index 0000000..8f4cdd2 --- /dev/null +++ b/app/IssueEvent.hs @@ -0,0 +1,54 @@ +module IssueEvent (IssueEvent (..)) where + +import Data.Binary (Binary) +import GHC.Generics (Generic) +import Git.CommitHash (CommitHash) +import Issue (Issue) +import Issue.Render qualified as I +import Patch (Patch) +import Render ((<<<)) +import Render qualified as P + +data IssueEvent + = IssueCreated + { hash :: CommitHash, + issue :: Issue, + patch :: Patch + } + | IssueChanged + { hash :: CommitHash, + oldIssue :: Issue, + issue :: Issue, + patch :: Patch + } + | IssueDeleted + { hash :: CommitHash, + issue :: Issue, + patch :: Patch + } + deriving (Show, Generic, Binary) + +instance P.Render IssueEvent where + render = P.render . P.Detailed + +instance P.Render (P.Detailed IssueEvent) where + render (P.Detailed issueEvent) = + P.Summarized issueEvent + <<< P.hardline @P.AnsiStyle + <<< issueEvent.patch + +instance P.Render (P.Summarized IssueEvent) where + render (P.Summarized issueEvent) = + case issueEvent of + IssueCreated {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "created" + <<< I.IssueTitle issue + IssueChanged {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "changed" + <<< I.IssueTitle issue + IssueDeleted {hash, issue} -> + P.Summarized hash + <<< P.styled [P.color P.Green] "deleted" + <<< I.IssueTitle issue |