1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Exit.Help
17import qualified Data.Text as Text
18import GHC.IO.Handle (hIsTerminalDevice)
19import System.IO (Handle, hPutStr, stderr, stdout)
21import qualified Json.Encode as Encode
22import Reporting.Doc ((<+>))
23import qualified Reporting.Doc as D
24import qualified Reporting.Exit.Compile as Compile
32 = CompilerReport Compile.Exit [Compile.Exit]
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 :: Compile.Exit -> [Compile.Exit] -> Report
64reportToDoc :: Report -> D.Doc
67 CompilerReport 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.fromString title <+> D.fromString errorBarEnd
87 D.stack [errorBar, message, ""]
94reportToJson :: Report -> Encode.Value
97 CompilerReport e es ->
99 [ ("type", Encode.text "compile-errors")
100 , ("errors", Encode.list Compile.toJson (e:es))
103 Report title maybePath message ->
105 [ ("type", Encode.text "error")
106 , ("path", maybe Encode.null (Encode.text . Text.pack) maybePath)
107 , ("title", Encode.text (Text.pack 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