1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit.Help
17import GHC.IO.Handle (hIsTerminalDevice)
18import System.IO (Handle, hPutStr, stderr, stdout)
20import qualified Json.Encode as E
21import Json.Encode ((==>))
22import Reporting.Doc ((<+>))
23import qualified Reporting.Doc as D
24import qualified Reporting.Error as Error
32 = CompilerReport FilePath Error.Module [Error.Module]
35 , _path :: Maybe FilePath
40report :: String -> Maybe FilePath -> String -> [D.Doc] -> Report
41report title path startString others =
42 Report title path $ D.stack (D.reflow startString:others)
45docReport :: String -> Maybe FilePath -> D.Doc -> [D.Doc] -> Report
46docReport title path startDoc others =
47 Report title path $ D.stack (startDoc:others)
50jsonReport :: String -> Maybe FilePath -> D.Doc -> Report
55compilerReport :: FilePath -> Error.Module -> [Error.Module] -> Report
64reportToDoc :: Report -> D.Doc
67 CompilerReport root e es ->
70 Report title maybePath message ->
73 replicate (max 1 (80 - n)) '-'
78 makeDashes (4 + length title)
81 makeDashes (5 + length title + length path) ++ " " ++ path
85 "--" <+> D.fromChars title <+> D.fromChars errorBarEnd
87 D.stack [errorBar, message, ""]
94reportToJson :: Report -> E.Value
97 CompilerReport _ e es ->
99 [ "type" ==> E.chars "compile-errors"
100 , "errors" ==> E.list Error.toJson (e:es)
103 Report title maybePath message ->
105 [ "type" ==> E.chars "error"
106 , "path" ==> maybe E.null E.chars maybePath
107 , "title" ==> E.chars title
108 , "message" ==> D.encode message
116toString :: D.Doc -> String
121toStdout :: D.Doc -> IO ()
126toStderr :: D.Doc -> IO ()
131toHandle :: Handle -> D.Doc -> IO ()
133 do isTerminal <- hIsTerminalDevice handle
135 then D.toAnsi handle doc
136 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