1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Error.Help
19import qualified Data.List as List
20import GHC.IO.Handle (hIsTerminalDevice)
21import System.IO (Handle, hPutStr, stderr, stdout)
22import qualified Text.PrettyPrint.ANSI.Leijen as P
23import Text.PrettyPrint.ANSI.Leijen ((<>),(<+>))
25import qualified Elm.Compiler as Compiler
26import qualified Elm.Package as Pkg
37 , _path :: Maybe FilePath
43report :: String -> Maybe FilePath -> String -> [P.Doc] -> Report
44report title maybePath startString others =
45 Report title maybePath (P.text startString) others
48docReport :: String -> Maybe FilePath -> P.Doc -> [P.Doc] -> Report
53compilerReport :: P.Doc -> Report
58reportToDoc :: Report -> P.Doc
64 Report title maybePath start others ->
67 replicate (max 1 (80 - n)) '-'
72 makeDashes (4 + length title)
75 makeDashes (5 + length title + length path) ++ " " ++ path
79 "--" <+> P.text title <+> P.text errorBarEnd
81 stack (errorBar : start : others ++ [""])
88hintLink :: String -> String
90 "<https://github.com/elm-lang/elm-compiler/blob/"
91 ++ Pkg.versionToString Compiler.version
92 ++ "/hints/" ++ hintName ++ ".md>"
99stack :: [P.Doc] -> P.Doc
103 error "Do not use `stack` on empty lists."
106 List.foldl' verticalAppend doc docs
109verticalAppend :: P.Doc -> P.Doc -> P.Doc
111 a <> P.hardline <> P.hardline <> b
114reflow :: String -> P.Doc
116 P.fillSep (map P.text (words paragraph))
119note :: String -> P.Doc
122 (P.underline "Note" <> ":") : map P.text (words details)
129toString :: P.Doc -> String
131 P.displayS (P.renderPretty 1 80 (P.plain doc)) ""
134toStdout :: P.Doc -> IO ()
139toStderr :: P.Doc -> IO ()
144toHandle :: Handle -> P.Doc -> IO ()
146 do isTerminal <- hIsTerminalDevice handle
148 then P.displayIO handle (P.renderPretty 1 80 doc)
149 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