on master help sign in
add silent style to reporting
7d06451Evan Czaplicki
builder/src/Reporting.hs+20−1
@@ -1,6 +1,7 @@
1{-# LANGUAGE BangPatterns, OverloadedStrings #-}
1{-# LANGUAGE BangPatterns, OverloadedStrings #-}
2module Reporting
2module Reporting
3 ( Style
3 ( Style
4+ , silent
4 , json
5 , json
5 , terminal
6 , terminal
6 --
7 --
@@ -49,10 +50,16 @@ import qualified Reporting.Exit.Help as Help
49
50
50
51
51data Style
52data Style
53+ = Silent
52− = Json
54+ | Json
53 | Terminal (MVar ())
55 | Terminal (MVar ())
54
56
55
57
58+silent :: Style
59+silent =
60+ Silent
61+
62+
56json :: Style
63json :: Style
57json =
64json =
58 Json
65 Json
@@ -84,6 +91,9 @@ attemptWithStyle style toReport work =
84 Right a -> return a
91 Right a -> return a
85 Left x ->
92 Left x ->
86 case style of
93 case style of
94+ Silent ->
95+ do Exit.exitFailure
96+
87 Json ->
97 Json ->
88 do B.hPutBuilder stderr (Encode.encodeUgly (Exit.toJson (toReport x)))
98 do B.hPutBuilder stderr (Encode.encodeUgly (Exit.toJson (toReport x)))
89 Exit.exitFailure
99 Exit.exitFailure
@@ -168,6 +178,9 @@ type DKey = Key DMsg
168trackDetails :: Style -> (DKey -> IO a) -> IO a
178trackDetails :: Style -> (DKey -> IO a) -> IO a
169trackDetails style callback =
179trackDetails style callback =
170 case style of
180 case style of
181+ Silent ->
182+ callback (Key (\_ -> return ()))
183+
171 Json ->
184 Json ->
172 callback (Key (\_ -> return ()))
185 callback (Key (\_ -> return ()))
173
186
@@ -297,6 +310,9 @@ type BResult a = Either Exit.BuildProblem a
297trackBuild :: Style -> (BKey -> IO (BResult a)) -> IO (BResult a)
310trackBuild :: Style -> (BKey -> IO (BResult a)) -> IO (BResult a)
298trackBuild style callback =
311trackBuild style callback =
299 case style of
312 case style of
313+ Silent ->
314+ callback (Key (\_ -> return ()))
315+
300 Json ->
316 Json ->
301 callback (Key (\_ -> return ()))
317 callback (Key (\_ -> return ()))
302
318
@@ -366,6 +382,9 @@ toFinalMessage done result =
366reportGenerate :: Style -> NE.List ModuleName.Raw -> FilePath -> IO ()
382reportGenerate :: Style -> NE.List ModuleName.Raw -> FilePath -> IO ()
367reportGenerate style names output =
383reportGenerate style names output =
368 case style of
384 case style of
385+ Silent ->
386+ return ()
387+
369 Json ->
388 Json ->
370 return ()
389 return ()
371
390