Commit 63d44818 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add putColoured.

parent 11ad7076
......@@ -7,6 +7,7 @@ module Oracles.Builder (
import Data.Char
import Base
import Util
import Oracles.Base
import Oracles.Flag
import Oracles.Option
......@@ -108,9 +109,11 @@ run builder as = do
terseRun :: ShowArgs a => Builder -> a -> Action ()
terseRun builder as = do
args <- showArgs as
putNormal $ "/--------\n| Running " ++ show builder ++ " with arguments:"
mapM_ (putNormal . ("| " ++)) $ interestingInfo builder args
putNormal "\\--------"
putColoured Vivid White $ "/--------\n" ++
"| Running " ++ show builder ++ " with arguments:"
mapM_ (putColoured Vivid White . ("| " ++)) $
interestingInfo builder args
putColoured Vivid White $ "\\--------"
quietly $ run builder as
interestingInfo :: Builder -> [String] -> [String]
......
module Util (
module Data.Char,
module System.Console.ANSI,
replaceIf, replaceEq, replaceSeparators,
chunksOfSize
chunksOfSize,
putColoured
) where
import Base
import Data.Char
import System.Console.ANSI
import System.IO
replaceIf :: (a -> Bool) -> a -> [a] -> [a]
replaceIf p to = map (\from -> if p from then to else from)
......@@ -30,3 +34,10 @@ chunksOfSize size ss = reverse chunk : chunksOfSize size rest
if newSize > size
then (chunk , s:ss)
else (newChunk, rest)
putColoured :: ColorIntensity -> Color -> String -> Action ()
putColoured intensity colour msg = do
liftIO $ setSGR [SetColor Foreground intensity colour]
putNormal msg
liftIO $ setSGR []
liftIO $ hFlush stdout
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment