on master help sign in
add silent style to reporting
commit7d064511b4c88a83c2a9848271a13e6932e70a59 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 4 Jun 2019, 00:28 (7 years ago) parent0b55695
1 file changed+20−1
builder/src/Reporting.hs+20−1
builder/src/Reporting.hs+20−1
@@ -1,6 +1,7 @@
11{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22module Reporting
33 ( Style
4+ , silent
45 , json
56 , terminal
67 --
@@ -49,10 +50,16 @@ import qualified Reporting.Exit.Help as Help
4950
5051
5152data Style
52− = Json
53+ = Silent
54+ | Json
5355 | Terminal (MVar ())
5456
5557
58+silent :: Style
59+silent =
60+ Silent
61+
62+
5663json :: Style
5764json =
5865 Json
@@ -84,6 +91,9 @@ attemptWithStyle style toReport work =
8491 Right a -> return a
8592 Left x ->
8693 case style of
94+ Silent ->
95+ do Exit.exitFailure
96+
8797 Json ->
8898 do B.hPutBuilder stderr (Encode.encodeUgly (Exit.toJson (toReport x)))
8999 Exit.exitFailure
@@ -168,6 +178,9 @@ type DKey = Key DMsg
168178trackDetails :: Style -> (DKey -> IO a) -> IO a
169179trackDetails style callback =
170180 case style of
181+ Silent ->
182+ callback (Key (\_ -> return ()))
183+
171184 Json ->
172185 callback (Key (\_ -> return ()))
173186
@@ -297,6 +310,9 @@ type BResult a = Either Exit.BuildProblem a
297310trackBuild :: Style -> (BKey -> IO (BResult a)) -> IO (BResult a)
298311trackBuild style callback =
299312 case style of
313+ Silent ->
314+ callback (Key (\_ -> return ()))
315+
300316 Json ->
301317 callback (Key (\_ -> return ()))
302318
@@ -366,6 +382,9 @@ toFinalMessage done result =
366382reportGenerate :: Style -> NE.List ModuleName.Raw -> FilePath -> IO ()
367383reportGenerate style names output =
368384 case style of
385+ Silent ->
386+ return ()
387+
369388 Json ->
370389 return ()
371390