diff options
| author | Joey Hess <joey@kitenet.net> | 2014-05-31 21:03:08 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-05-31 21:03:08 -0400 |
| commit | 2588cab6a2b8e3097fa23b3527d9fa8d9c53d903 (patch) | |
| tree | c6768a2c122b2d466506edbe856a100d0c7ec033 /src/Propellor/Message.hs | |
| parent | 67549db9e95e03c449f1ad6969605801cd731656 (diff) | |
| parent | 179301f58dea22feb945004389a56662fe255138 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Message.hs')
| -rw-r--r-- | src/Propellor/Message.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs index 780471c3..afbed1ca 100644 --- a/src/Propellor/Message.hs +++ b/src/Propellor/Message.hs @@ -12,7 +12,15 @@ import Propellor.Types -- | Shows a message while performing an action, with a colored status -- display. actionMessage :: (MonadIO m, ActionResult r) => Desc -> m r -> m r -actionMessage desc a = do +actionMessage = actionMessage' Nothing + +-- | Shows a message while performing an action on a specified host, +-- with a colored status display. +actionMessageOn :: (MonadIO m, ActionResult r) => HostName -> Desc -> m r -> m r +actionMessageOn = actionMessage' . Just + +actionMessage' :: (MonadIO m, ActionResult r) => Maybe HostName -> Desc -> m r -> m r +actionMessage' mhn desc a = do liftIO $ do setTitle $ "propellor: " ++ desc hFlush stdout @@ -21,12 +29,19 @@ actionMessage desc a = do liftIO $ do setTitle "propellor: running" - let (msg, intensity, color) = getActionResult r + showhn mhn putStr $ desc ++ " ... " + let (msg, intensity, color) = getActionResult r colorLine intensity color msg hFlush stdout return r + where + showhn Nothing = return () + showhn (Just hn) = do + setSGR [SetColor Foreground Dull Cyan] + putStr (hn ++ " ") + setSGR [] warningMessage :: MonadIO m => String -> m () warningMessage s = liftIO $ colorLine Vivid Magenta $ "** warning: " ++ s |
