From dd08ae61dbbf01e9ed8a69549b14892057a375bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 00:18:51 -0400 Subject: propellor spin --- .gitignore | 1 + Propellor/Message.hs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a2bed361..e9925509 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ privdata/keyring.gpg~ Setup Setup.hi Setup.o +docker diff --git a/Propellor/Message.hs b/Propellor/Message.hs index eb3f3177..5a7d8c4b 100644 --- a/Propellor/Message.hs +++ b/Propellor/Message.hs @@ -15,21 +15,25 @@ actionMessage desc a = do r <- a + setTitle "propellor: running" let (msg, intensity, color) = getActionResult r putStr $ desc ++ " ... " - setSGR [SetColor Foreground intensity color] - putStrLn msg - setSGR [] - setTitle "propellor: running" + colorLine intensity color msg hFlush stdout return r warningMessage :: String -> IO () -warningMessage s = do - setSGR [SetColor Foreground Vivid Red] - putStrLn $ "** warning: " ++ s +warningMessage s = colorLine Vivid Red $ "** warning: " ++ s + +colorLine :: ColorIntensity -> Color -> String -> IO () +colorLine intensity color msg = do + setSGR [SetColor Foreground intensity color] + putStr msg setSGR [] + -- Note this comes after the color is reset, so that + -- the color set and reset happen in the same line. + putStrLn "" hFlush stdout errorMessage :: String -> IO a -- cgit v1.2.3