diff options
| author | Joey Hess <joey@kitenet.net> | 2014-03-30 23:55:59 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-03-30 23:55:59 -0400 |
| commit | 8621fa6e9983a39c07a9677eac324ebcee79b549 (patch) | |
| tree | af60e05e58dc49d2f73d326f8ed1fb51d74f3704 /Propellor/Property/Cmd.hs | |
| parent | 8f2ac23b41c6bbc24c658831a6a988c0d23a9f7d (diff) | |
more prep for hackage
Diffstat (limited to 'Propellor/Property/Cmd.hs')
| -rw-r--r-- | Propellor/Property/Cmd.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Propellor/Property/Cmd.hs b/Propellor/Property/Cmd.hs index 6e23955c..88a84968 100644 --- a/Propellor/Property/Cmd.hs +++ b/Propellor/Property/Cmd.hs @@ -1,8 +1,7 @@ module Propellor.Property.Cmd ( cmdProperty, cmdProperty', - scriptProperty, - module Utility.SafeCommand + scriptProperty ) where import Control.Applicative @@ -13,23 +12,26 @@ import Utility.Monad import Utility.SafeCommand import Utility.Env -cmdProperty :: String -> [CommandParam] -> Property +-- | A property that can be satisfied by running a command. +-- +-- The command must exit 0 on success. +cmdProperty :: String -> [String] -> Property cmdProperty cmd params = cmdProperty' cmd params [] -cmdProperty' :: String -> [CommandParam] -> [(String, String)] -> Property +-- | A property that can be satisfied by running a command, +-- with added environment. +cmdProperty' :: String -> [String] -> [(String, String)] -> Property cmdProperty' cmd params env = Property desc $ do env' <- addEntries env <$> getEnvironment - ifM (boolSystemEnv cmd params (Just env')) + ifM (boolSystemEnv cmd (map Param params) (Just env')) ( return MadeChange , return FailedChange ) where - desc = unwords $ cmd : map showp params - showp (Params s) = s - showp (Param s) = s - showp (File s) = s + desc = unwords $ cmd : params +-- | A property that can be satisfied by running a series of shell commands. scriptProperty :: [String] -> Property -scriptProperty script = cmdProperty "sh" [Param "-c", Param shellcmd] +scriptProperty script = cmdProperty "sh" ["-c", shellcmd] where shellcmd = intercalate " ; " ("set -e" : script) |
