propellor spin

This commit is contained in:
Joey Hess 2014-03-30 20:23:23 -04:00
parent 614d497895
commit e563b8cdf6
2 changed files with 9 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import Data.Maybe
import Control.Monad
import Types
import Property
import Utility.Monad
import Utility.PartialPrelude
import Utility.Exception
@ -29,8 +30,7 @@ withPrivData :: PrivDataField -> (String -> IO Result) -> IO Result
withPrivData field a = maybe missing a =<< getPrivData field
where
missing = do
hPutStrLn stderr $ "** Missing privdata " ++ show field
hFlush stderr
warningMessage $ "Missing privdata " ++ show field
return FailedChange
getPrivData :: PrivDataField -> IO (Maybe String)

View File

@ -116,3 +116,10 @@ ensureProperties' ps = ensure ps NoChange
putStrLn "done"
setSGR []
ensure ls (combineResult r rs)
warningMessage :: String -> IO ()
warningMessage s = do
setSGR [SetColor Foreground Vivid Red]
putStrLn $ "** warning: " ++ s
setSGR []
hFlush stdout