diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-11 01:09:01 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-11 01:09:01 -0400 |
| commit | 856ce97995bc34e35fd8e0233341f26a37b19cf5 (patch) | |
| tree | 1d93492b36cd07d58437d2cb0f902ad53b3abe6e /Propellor/Message.hs | |
| parent | 07a071ac7f5b2f71e376a9a1a78a84a6bf02129b (diff) | |
| parent | 47ff089f844c707eaa3ffd7255dc733721fb6adf (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'Propellor/Message.hs')
| -rw-r--r-- | Propellor/Message.hs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Propellor/Message.hs b/Propellor/Message.hs index 5a7d8c4b..2e63061e 100644 --- a/Propellor/Message.hs +++ b/Propellor/Message.hs @@ -1,30 +1,35 @@ +{-# LANGUAGE PackageImports #-} + module Propellor.Message where import System.Console.ANSI import System.IO import System.Log.Logger +import "mtl" Control.Monad.Reader import Propellor.Types -- | Shows a message while performing an action, with a colored status -- display. -actionMessage :: ActionResult r => Desc -> IO r -> IO r +actionMessage :: (MonadIO m, ActionResult r) => Desc -> m r -> m r actionMessage desc a = do - setTitle $ "propellor: " ++ desc - hFlush stdout + liftIO $ do + setTitle $ "propellor: " ++ desc + hFlush stdout r <- a - setTitle "propellor: running" - let (msg, intensity, color) = getActionResult r - putStr $ desc ++ " ... " - colorLine intensity color msg - hFlush stdout + liftIO $ do + setTitle "propellor: running" + let (msg, intensity, color) = getActionResult r + putStr $ desc ++ " ... " + colorLine intensity color msg + hFlush stdout return r -warningMessage :: String -> IO () -warningMessage s = colorLine Vivid Red $ "** warning: " ++ s +warningMessage :: MonadIO m => String -> m () +warningMessage s = liftIO $ colorLine Vivid Red $ "** warning: " ++ s colorLine :: ColorIntensity -> Color -> String -> IO () colorLine intensity color msg = do |
