Safe Haskell | None |
---|---|
Language | Haskell2010 |
Reading from external processes.
- withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- data EnvOverride = EnvOverride {
- eoTextMap :: Map Text Text
- eoStringList :: [(String, String)]
- eoPath :: [FilePath]
- eoExeCache :: IORef (Map FilePath (Either ReadProcessException FilePath))
- eoExeExtensions :: [String]
- eoWorkingDir :: !(Maybe FilePath)
- unEnvOverride :: EnvOverride -> Map Text Text
- mkEnvOverride :: MonadIO m => Map Text Text -> m EnvOverride
- modifyEnvOverride :: MonadIO m => EnvOverride -> (Map Text Text -> Map Text Text) -> m EnvOverride
- envHelper :: EnvOverride -> [(String, String)]
- doesExecutableExist :: MonadIO m => EnvOverride -> String -> m Bool
- findExecutable :: (MonadIO m, MonadThrow n) => EnvOverride -> String -> m (n FilePath)
- getEnvOverride :: MonadIO m => m EnvOverride
- envSearchPath :: EnvOverride -> [FilePath]
- preProcess :: HasEnvOverride env => String -> RIO env FilePath
- readProcessNull :: HasEnvOverride env => String -> [String] -> RIO env ()
- data ReadProcessException
- augmentPath :: MonadThrow m => [FilePath] -> Maybe Text -> m Text
- augmentPathMap :: MonadThrow m => [FilePath] -> Map Text Text -> m (Map Text Text)
- resetExeCache :: MonadIO m => EnvOverride -> m ()
- class HasLogFunc env => HasEnvOverride env where
- workingDirL :: HasEnvOverride env => Lens' env (Maybe FilePath)
- withProc :: HasEnvOverride env => FilePath -> [String] -> (ProcessConfig () () () -> RIO env a) -> RIO env a
- withEnvOverride :: HasEnvOverride env => EnvOverride -> RIO env a -> RIO env a
- withModifyEnvOverride :: HasEnvOverride env => (Map Text Text -> Map Text Text) -> RIO env a -> RIO env a
- withWorkingDir :: HasEnvOverride env => FilePath -> RIO env a -> RIO env a
- runEnvNoLogging :: RIO EnvNoLogging a -> IO a
- withProcessTimeLog :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Maybe FilePath -> String -> [String] -> m a -> m a
- showProcessArgDebug :: String -> Text
- exec :: HasEnvOverride env => String -> [String] -> RIO env b
- execSpawn :: HasEnvOverride env => String -> [String] -> RIO env a
- execObserve :: HasEnvOverride env => String -> [String] -> RIO env String
- module System.Process.Typed
Documentation
withProcess :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a Source #
Same as withProcess
, but generalized to MonadUnliftIO
.
withProcess_ :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a Source #
Same as withProcess_
, but generalized to MonadUnliftIO
.
data EnvOverride Source #
Override the environment received by a child process.
EnvOverride | |
|
unEnvOverride :: EnvOverride -> Map Text Text Source #
Get the environment variables from an EnvOverride
.
mkEnvOverride :: MonadIO m => Map Text Text -> m EnvOverride Source #
Create a new EnvOverride
.
modifyEnvOverride :: MonadIO m => EnvOverride -> (Map Text Text -> Map Text Text) -> m EnvOverride Source #
Modify the environment variables of an EnvOverride
.
:: MonadIO m | |
=> EnvOverride | How to override environment |
-> String | Name of executable |
-> m Bool |
Check if the given executable exists on the given PATH.
:: (MonadIO m, MonadThrow n) | |
=> EnvOverride | How to override environment |
-> String | Name of executable |
-> m (n FilePath) | Full path to that executable on success |
Find the complete path for the executable.
Throws a ReadProcessException
if unsuccessful.
getEnvOverride :: MonadIO m => m EnvOverride Source #
Load up an EnvOverride
from the standard environment.
envSearchPath :: EnvOverride -> [FilePath] Source #
Get the list of directories searched (PATH
).
:: HasEnvOverride env | |
=> String | Command name |
-> RIO env FilePath |
Perform pre-call-process tasks. Ensure the working directory exists and find the executable path.
Throws a ReadProcessException
if unsuccessful.
:: HasEnvOverride env | |
=> String | Command |
-> [String] | Command line arguments |
-> RIO env () |
Read from the process, ignoring any output.
Throws a ReadProcessException
exception if the process fails.
data ReadProcessException Source #
An exception while trying to read from process.
augmentPath :: MonadThrow m => [FilePath] -> Maybe Text -> m Text Source #
Augment the PATH environment variable with the given extra paths.
augmentPathMap :: MonadThrow m => [FilePath] -> Map Text Text -> m (Map Text Text) Source #
Apply augmentPath
on the PATH value in the given Map.
resetExeCache :: MonadIO m => EnvOverride -> m () Source #
Reset the executable cache.
class HasLogFunc env => HasEnvOverride env where Source #
envOverrideL :: Lens' env EnvOverride Source #
workingDirL :: HasEnvOverride env => Lens' env (Maybe FilePath) Source #
:: HasEnvOverride env | |
=> FilePath | command to run |
-> [String] | command line arguments |
-> (ProcessConfig () () () -> RIO env a) | |
-> RIO env a |
Provide a ProcessConfig
based on the EnvOverride
in
scope. Deals with resolving the full path, setting the child
process's environment variables, setting the working directory, and
wrapping the call with withProcessTimeLog
for debugging output.
withEnvOverride :: HasEnvOverride env => EnvOverride -> RIO env a -> RIO env a Source #
Set a new EnvOverride
in the child reader. Note that this will
keep the working directory set in the parent with withWorkingDir
.
withModifyEnvOverride :: HasEnvOverride env => (Map Text Text -> Map Text Text) -> RIO env a -> RIO env a Source #
Apply the given function to the modified environment
variables. For more details, see withEnvOverride
.
withWorkingDir :: HasEnvOverride env => FilePath -> RIO env a -> RIO env a Source #
Set the working directory to be used by child processes.
runEnvNoLogging :: RIO EnvNoLogging a -> IO a Source #
withProcessTimeLog :: (MonadIO m, MonadReader env m, HasLogFunc env, HasCallStack) => Maybe FilePath -> String -> [String] -> m a -> m a Source #
Log running a process with its arguments, for debugging (-v).
This logs one message before running the process and one message after.
showProcessArgDebug :: String -> Text Source #
Show a process arg including speechmarks when necessary. Just for debugging purposes, not functionally important.
exec :: HasEnvOverride env => String -> [String] -> RIO env b Source #
Execute a process within the Stack configured environment.
Execution will not return, because either:
1) On non-windows, execution is taken over by execv of the sub-process. This allows signals to be propagated (#527)
2) On windows, an ExitCode
exception will be thrown.
execObserve :: HasEnvOverride env => String -> [String] -> RIO env String Source #
module System.Process.Typed