aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-27 09:52:36 +0100
committertv <tv@krebsco.de>2019-01-27 09:52:36 +0100
commit32ddebc0309a73c50e0f1974b4f9435fce3f86c9 (patch)
tree668171efc58a85e11b1d1e37ad2d71b021671b1f
parente9ca12a945b1d1c068e9c31050e264cb20690db4 (diff)
Reaktor.Plugins.System: Command -> SystemCommand
-rw-r--r--src/Reaktor/Plugins/System.hs10
-rw-r--r--src/Reaktor/Plugins/System/Internal.hs16
2 files changed, 13 insertions, 13 deletions
diff --git a/src/Reaktor/Plugins/System.hs b/src/Reaktor/Plugins/System.hs
index 864bbc3..8ca468c 100644
--- a/src/Reaktor/Plugins/System.hs
+++ b/src/Reaktor/Plugins/System.hs
@@ -90,7 +90,7 @@ run1 Config{..} Actions{..} Hook{..} prefix msgtarget text = do
name =
case hCommand of
Capture i -> fromMaybe "<unnamed>" (capture i)
- CaptureOr Command{..} -> T.pack $ takeBaseName $ commandPath
+ CaptureOr SystemCommand{..} -> T.pack $ takeBaseName $ scPath
command =
case hCommand of
@@ -106,7 +106,7 @@ run1 Config{..} Actions{..} Hook{..} prefix msgtarget text = do
CaptureOr s -> Just s
case command of
- Just Command{..} -> do
+ Just SystemCommand{..} -> do
baseEnv <- getEnvironment
let
@@ -138,13 +138,13 @@ run1 Config{..} Actions{..} Hook{..} prefix msgtarget text = do
env =
M.toList $ mconcat
[ M.fromList extraEnv
- , maybe mempty id commandEnv
+ , maybe mempty id scEnv
, M.fromList baseEnv
]
- cwd = commandWorkDir <|> hWorkDir <|> cWorkDir
+ cwd = scWorkDir <|> hWorkDir <|> cWorkDir
- fork commandPath args cwd (Just env) "" hTimeout Callbacks{..}
+ fork scPath args cwd (Just env) "" hTimeout Callbacks{..}
Nothing -> do
let s = name <> ": command not found"
diff --git a/src/Reaktor/Plugins/System/Internal.hs b/src/Reaktor/Plugins/System/Internal.hs
index d042217..78c8802 100644
--- a/src/Reaktor/Plugins/System/Internal.hs
+++ b/src/Reaktor/Plugins/System/Internal.hs
@@ -49,10 +49,10 @@ instance FromJSON Config where
data Hook = Hook
{ hActivate :: Activate
, hPattern :: Maybe Regex
- , hCommand :: CaptureOr Command
+ , hCommand :: CaptureOr SystemCommand
, hArguments :: [CaptureOr Text]
, hWorkDir :: Maybe FilePath
- , hCommands :: HashMap Text Command
+ , hCommands :: HashMap Text SystemCommand
, hTimeout :: Maybe Int
}
deriving Show
@@ -71,17 +71,17 @@ instance FromJSON Hook where
_ -> undefined
-data Command = Command
- { commandPath :: FilePath
- , commandWorkDir :: Maybe FilePath
- , commandEnv :: Maybe (HashMap String String)
+data SystemCommand = SystemCommand
+ { scPath :: FilePath
+ , scWorkDir :: Maybe FilePath
+ , scEnv :: Maybe (HashMap String String)
}
deriving Show
-instance FromJSON Command where
+instance FromJSON SystemCommand where
parseJSON = \case
Object v ->
- Command
+ SystemCommand
<$> v .: "filename"
<*> v .:? "workdir"
<*> v .:? "env"