summaryrefslogtreecommitdiff
path: root/src/Propellor/Engine.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-22 12:13:41 -0400
committerJoey Hess2014-11-22 12:13:41 -0400
commit7cbf4841de39761953cf31d32ed86bb4bd949672 (patch)
tree3d8bb9ecd83a24494a40de5211a10f19036a2949 /src/Propellor/Engine.hs
parent557fab609175d7d0a59ffe1269fed02f49f8004e (diff)
parent57ec60d6f307dbf3e237b924e635b90ba889af18 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Engine.hs')
-rw-r--r--src/Propellor/Engine.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs
index 969769ce..b551ca05 100644
--- a/src/Propellor/Engine.hs
+++ b/src/Propellor/Engine.hs
@@ -11,7 +11,6 @@ import "mtl" Control.Monad.Reader
import Control.Exception (bracket)
import System.PosixCompat
import System.Posix.IO
-import Data.Maybe
import Propellor.Types
import Propellor.Message
@@ -28,7 +27,9 @@ mainProperties :: Host -> IO ()
mainProperties host = do
r <- runPropellor host $
ensureProperties [Property "overall" (ensureProperties $ hostProperties host) mempty]
- setTitle "propellor: done"
+ h <- mkMessageHandle
+ whenConsole h $
+ setTitle "propellor: done"
hFlush stdout
case r of
FailedChange -> exitWith (ExitFailure 1)
@@ -74,8 +75,14 @@ processChainOutput h = go Nothing
go lastline = do
v <- catchMaybeIO (hGetLine h)
case v of
- Nothing -> pure $ fromMaybe FailedChange $
- readish =<< lastline
+ Nothing -> case lastline of
+ Nothing -> pure FailedChange
+ Just l -> case readish l of
+ Just r -> pure r
+ Nothing -> do
+ putStrLn l
+ hFlush stdout
+ return FailedChange
Just s -> do
maybe noop (\l -> unless (null l) (putStrLn l)) lastline
hFlush stdout