1module Main (main) where
3import CompaREST.GitHub.API
4import CompaREST.GitHub.Action.Config
5import Control.Exception
6import Control.Monad.Freer
7import Control.Monad.Freer.Error
8import Control.Monad.Freer.GitHub
9import Control.Monad.Freer.Reader
10import Data.OpenApi.Compare.Run
11import Data.Text (Text)
12import qualified Data.Text as T
13import qualified Data.Yaml.Aeson as Yaml
14import qualified GitHub as GH
15import System.Environment
16import System.Envy (decodeEnv)
17import System.FilePath ((</>))
18import Text.Pandoc (runPure)
19import Text.Pandoc.Builder
20import Text.Pandoc.Options
21import Text.Pandoc.Writers
25 cfg <- decodeEnv >>= either error pure
27 x | T.null . T.strip . GH.untagName $ x -> do
28 putStrLn "SHA not specified. Exiting without doing anything."
34 oldFile <- getEnv "OLD"
35 newFile <- getEnv "NEW"
36 runRun cfg (root cfg </> oldFile) (root cfg </> newFile)
37 _ -> error "Invalid arguments."
39runner :: Config -> Eff '[GitHub, Error GH.Error, Reader Config, IO] a -> IO a
41 runM @IO . runReader cfg
42 . flip (handleError @GH.Error) (error . displayException)
43 . runGitHub (githubToken cfg)
45runPre :: Config -> IO ()
46runPre cfg = runner cfg postStatusProcessing
48runRun :: Config -> FilePath -> FilePath -> IO ()
49runRun cfg old' new' = runner cfg $ do
50 old <- Yaml.decodeFileThrow old'
51 new <- Yaml.decodeFileThrow new'
54 { treeStyle = FoldingBlockquotesTreeStyle
57 (report, status) = runReport reportConfig (old, new)
59 body = markdown report <> "\n\n" <> footerText cfg
64 else Just (body, status)
67markdown :: Blocks -> Text
69 either (error . displayException) id
71 . writeHtml5String def
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list