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.Yaml.Aeson as Yaml
13import qualified GitHub as GH
14import System.Environment
15import System.Envy (decodeEnv)
16import System.FilePath ((</>))
17import Text.Pandoc (runPure)
18import Text.Pandoc.Builder
19import Text.Pandoc.Options
20import Text.Pandoc.Writers
24 cfg <- decodeEnv >>= either error pure
28 oldFile <- getEnv "OLD"
29 newFile <- getEnv "NEW"
30 runRun cfg (root cfg </> oldFile) (root cfg </> newFile)
31 _ -> error "Invalid arguments."
33runner :: Config -> Eff '[GitHub, Error GH.Error, Reader Config, IO] a -> IO a
35 runM @IO . runReader cfg
36 . flip (handleError @GH.Error) (error . displayException)
37 . runGitHub (githubToken cfg)
39runPre :: Config -> IO ()
40runPre cfg = runner cfg postStatusProcessing
42runRun :: Config -> FilePath -> FilePath -> IO ()
43runRun cfg old' new' = runner cfg $ do
44 old <- Yaml.decodeFileThrow old'
45 new <- Yaml.decodeFileThrow new'
48 { treeStyle = FoldingBlockquotesTreeStyle
51 (report, status) = runReport reportConfig (old, new)
53 body = markdown report <> "\n\n" <> footerText cfg
58 else Just (body, status)
61markdown :: Blocks -> Text
63 either (error . displayException) id
65 . 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