propellor spin
This commit is contained in:
parent
84eb050085
commit
4c96b0681c
|
@ -33,7 +33,7 @@ ensureProperties ps = ensure ps NoChange
|
||||||
ensure [] rs = return rs
|
ensure [] rs = return rs
|
||||||
ensure (l:ls) rs = do
|
ensure (l:ls) rs = do
|
||||||
hn <- getHostName
|
hn <- getHostName
|
||||||
r <- actionMessage (hn ++ " " ++ propertyDesc l) (ensureProperty l)
|
r <- actionMessageOn hn (propertyDesc l) (ensureProperty l)
|
||||||
ensure ls (r <> rs)
|
ensure ls (r <> rs)
|
||||||
|
|
||||||
ensureProperty :: Property -> Propellor Result
|
ensureProperty :: Property -> Propellor Result
|
||||||
|
|
|
@ -12,7 +12,15 @@ import Propellor.Types
|
||||||
-- | Shows a message while performing an action, with a colored status
|
-- | Shows a message while performing an action, with a colored status
|
||||||
-- display.
|
-- display.
|
||||||
actionMessage :: (MonadIO m, ActionResult r) => Desc -> m r -> m r
|
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
|
liftIO $ do
|
||||||
setTitle $ "propellor: " ++ desc
|
setTitle $ "propellor: " ++ desc
|
||||||
hFlush stdout
|
hFlush stdout
|
||||||
|
@ -21,12 +29,19 @@ actionMessage desc a = do
|
||||||
|
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
setTitle "propellor: running"
|
setTitle "propellor: running"
|
||||||
let (msg, intensity, color) = getActionResult r
|
showhn mhn
|
||||||
putStr $ desc ++ " ... "
|
putStr $ desc ++ " ... "
|
||||||
|
let (msg, intensity, color) = getActionResult r
|
||||||
colorLine intensity color msg
|
colorLine intensity color msg
|
||||||
hFlush stdout
|
hFlush stdout
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
where
|
||||||
|
showhn Nothing = return ()
|
||||||
|
showhn (Just hn) = do
|
||||||
|
setSGR [SetColor Foreground Dull Cyan]
|
||||||
|
putStr (hn ++ " ")
|
||||||
|
setSGR []
|
||||||
|
|
||||||
warningMessage :: MonadIO m => String -> m ()
|
warningMessage :: MonadIO m => String -> m ()
|
||||||
warningMessage s = liftIO $ colorLine Vivid Magenta $ "** warning: " ++ s
|
warningMessage s = liftIO $ colorLine Vivid Magenta $ "** warning: " ++ s
|
||||||
|
|
Loading…
Reference in New Issue