diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-05-07 12:18:23 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-05-07 12:18:23 -0400 |
| commit | 49ca7cb93f49fac0ff89090b500d3d48968f2b18 (patch) | |
| tree | a2ca3d5e942650fe93561087aede9707e7f624c3 /src/Propellor/Property/Cmd.hs | |
| parent | 31bde3114b1f362fb1211f465c0ccfcaf82e468a (diff) | |
| parent | 63ccccb1bb3eb14f351b4e8745a952d8738c0f5e (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Cmd.hs')
| -rw-r--r-- | src/Propellor/Property/Cmd.hs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Propellor/Property/Cmd.hs b/src/Propellor/Property/Cmd.hs index e2b91db1..859302c8 100644 --- a/src/Propellor/Property/Cmd.hs +++ b/src/Propellor/Property/Cmd.hs @@ -3,6 +3,7 @@ module Propellor.Property.Cmd ( cmdProperty, cmdProperty', + cmdPropertyEnv, scriptProperty, userScriptProperty, ) where @@ -10,6 +11,7 @@ module Propellor.Property.Cmd ( import Control.Applicative import Data.List import "mtl" Control.Monad.Reader +import System.Process (CreateProcess) import Propellor.Types import Propellor.Property @@ -20,12 +22,19 @@ import Utility.Env -- -- The command must exit 0 on success. cmdProperty :: String -> [String] -> Property NoInfo -cmdProperty cmd params = cmdProperty' cmd params [] +cmdProperty cmd params = cmdProperty' cmd params id + +cmdProperty' :: String -> [String] -> (CreateProcess -> CreateProcess) -> Property NoInfo +cmdProperty' cmd params mkprocess = property desc $ liftIO $ do + toResult <$> boolSystem' cmd (map Param params) mkprocess + where + desc = unwords $ cmd : params -- | A property that can be satisfied by running a command, --- with added environment. -cmdProperty' :: String -> [String] -> [(String, String)] -> Property NoInfo -cmdProperty' cmd params env = property desc $ liftIO $ do +-- with added environment variables in addition to the standard +-- environment. +cmdPropertyEnv :: String -> [String] -> [(String, String)] -> Property NoInfo +cmdPropertyEnv cmd params env = property desc $ liftIO $ do env' <- addEntries env <$> getEnvironment toResult <$> boolSystemEnv cmd (map Param params) (Just env') where |
