From c246a8ee745723140150c8b8d35b7a7121c90c11 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Mar 2014 18:31:08 -0400 Subject: propellor spin --- Propellor/Types.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Propellor/Types.hs') diff --git a/Propellor/Types.hs b/Propellor/Types.hs index ec472ffe..5874863c 100644 --- a/Propellor/Types.hs +++ b/Propellor/Types.hs @@ -1,6 +1,7 @@ module Propellor.Types where import Data.Monoid +import System.Console.ANSI type HostName = String type UserName = String @@ -24,3 +25,15 @@ instance Monoid Result where mappend MadeChange _ = MadeChange mappend _ MadeChange = MadeChange mappend NoChange NoChange = NoChange + +class ActionResult a where + getActionResult :: a -> (String, ColorIntensity, Color) + +instance ActionResult Bool where + getActionResult False = ("ok", Vivid, Red) + getActionResult True = ("failed", Vivid, Green) + +instance ActionResult Result where + getActionResult NoChange = ("unchanged", Dull, Green) + getActionResult MadeChange = ("done", Vivid, Green) + getActionResult FailedChange = ("failed", Vivid, Red) -- cgit v1.2.3