forked from haskell-github/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchIssues.hs
More file actions
29 lines (26 loc) · 959 Bytes
/
SearchIssues.hs
File metadata and controls
29 lines (26 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified GitHub
import qualified Data.Text as T
import Control.Monad (forM_)
import Data.Monoid ((<>))
main :: IO ()
main = do
let query = "build repo:haskell-github/github"
result <- GitHub.github' GitHub.searchIssuesR query 1000
case result of
Left e -> putStrLn $ "Error: " ++ show e
Right r -> do
forM_ (GitHub.searchResultResults r) $ \r -> do
putStrLn $ formatIssue r
putStrLn ""
putStrLn $ "Count: " ++ show (GitHub.searchResultTotalCount r)
++ " matches for the query: \"" ++ T.unpack query ++ "\""
formatIssue :: GitHub.Issue -> String
formatIssue issue =
(show $ GitHub.issueUser issue) <>
" opened this issue " <>
(show $ GitHub.issueCreatedAt issue) <> "\n" <>
(show $ GitHub.issueState issue) <> " with " <>
(show $ GitHub.issueComments issue) <> " comments" <> "\n\n" <>
(T.unpack $ GitHub.issueTitle issue)