1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit.Help
17import qualified Data.Utf8 as Utf8
18import GHC.IO.Handle (hIsTerminalDevice)
19import System.IO (Handle, hPutStr, stderr, stdout)
21import qualified Json.Encode as E
22import Json.Encode ((==>))
23import Reporting.Doc ((<+>))
24import qualified Reporting.Doc as D
25import qualified Reporting.Exit.Compile as Compile
33 = CompilerReport Compile.Exit [Compile.Exit]
36 , _path :: Maybe FilePath
41report :: String -> Maybe FilePath -> String -> [D.Doc] -> Report
42report title path startString others =
43 Report title path $ D.stack (D.reflow startString:others)
46docReport :: String -> Maybe FilePath -> D.Doc -> [D.Doc] -> Report
47docReport title path startDoc others =
48 Report title path $ D.stack (startDoc:others)
51jsonReport :: String -> Maybe FilePath -> D.Doc -> Report
56compilerReport :: Compile.Exit -> [Compile.Exit] -> Report
65reportToDoc :: Report -> D.Doc
68 CompilerReport e es ->
71 Report title maybePath message ->
74 replicate (max 1 (80 - n)) '-'
79 makeDashes (4 + length title)
82 makeDashes (5 + length title + length path) ++ " " ++ path
86 "--" <+> D.fromChars title <+> D.fromChars errorBarEnd
88 D.stack [errorBar, message, ""]
95reportToJson :: Report -> E.Value
98 CompilerReport e es ->
100 [ "type" ==> E.string "compile-errors"
101 , "errors" ==> E.list Compile.toJson (e:es)
104 Report title maybePath message ->
106 [ "type" ==> E.string "error"
107 , "path" ==> maybe E.null (E.string . Utf8.fromChars) maybePath
108 , "title" ==> E.string (Utf8.fromChars title)
109 , "message" ==> D.encode message
117toString :: D.Doc -> String
122toStdout :: D.Doc -> IO ()
127toStderr :: D.Doc -> IO ()
132toHandle :: Handle -> D.Doc -> IO ()
134 do isTerminal <- hIsTerminalDevice handle
136 then D.toAnsi handle doc
137 else hPutStr handle (toString doc)
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