cli-extras-0.2.1.0: Miscellaneous utilities for building and working with command line interfaces
Safe HaskellNone
LanguageHaskell2010

Cli.Extras.Process

Description

An extension of Process that integrates with logging (Logging) and is thus spinner friendly.

Synopsis

Documentation

class AsProcessFailure e where Source #

Indicates arbitrary process failures form one variant (or conceptual projection) of the error type.

Instances

Instances details
AsProcessFailure ProcessFailure Source # 
Instance details

Defined in Cli.Extras.Process

callCommand :: (MonadIO m, CliLog m) => String -> m () Source #

Like callCommand, but logging (with Debug severity) the process which was started.

callProcess :: (MonadIO m, CliLog m) => String -> [String] -> m () Source #

Like callProcess, but logging (with Debug severity) the process which was started.

callProcessAndLogOutput Source #

Arguments

:: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadMask m) 
=> (Severity, Severity)

This tuple controls the severity of each output stream. Its fst is the severity of stdout; snd is the severity of stderr.

-> ProcessSpec 
-> m () 

Like readProcess, but such that each of the child processes' standard output streams (stdout and stderr) is logged, with the corresponding severity.

Usually, this function is called as callProcessAndLogOutput (Debug, Error). If the child process is known to print diagnostic or informative messages to stderr, it is advisable to call callProcessAndLogOutput with a non-Error severity for stderr, for example callProcessAndLogOutput (Debug, Debug).

createProcess :: (MonadIO m, CliLog m) => ProcessSpec -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

Like createProcess, but logging (with Debug severity) the process which was started.

createProcess_ :: (MonadIO m, CliLog m) => String -> ProcessSpec -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

Like createProcess_, but logging (with Debug severity) the process which was started.

throwExitCode :: (CliThrow e m, AsProcessFailure e) => ProcessSpec -> ExitCode -> m () Source #

Aborts the computation (using throwError) when given a non-ExitSuccess ExitCode.

readProcessAndLogOutput Source #

Arguments

:: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) 
=> (Severity, Severity)

This tuple controls the severity of each output stream. Its fst is the severity of stdout; snd is the severity of stderr.

-> ProcessSpec 
-> m Text 

Like readProcess, but such that each of the child processes' standard output streams (stdout and stderr) is logged, with the corresponding severity.

Usually, this function is called as readProcessAndLogOutput (Debug, Error). If the child process is known to print diagnostic or informative messages to stderr, it is advisable to call readProcessAndLogOutput with a non-Error severity for stderr, for example readProcessAndLogOutput (Debug, Debug).

reconstructCommand :: CmdSpec -> Text Source #

Pretty print a CmdSpec

runProcess_ :: (MonadIO m, CliLog m, CliThrow e m, MonadMask m, AsProcessFailure e) => ProcessSpec -> m () Source #

Runs a process to completion, aborting the computation (using throwExitCode) in case of a non-ExitSuccess exit status.

runProc :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m) => ProcessSpec -> m () Source #

A wrapper for callProcessAndLogOutput with sensible default verbosities: standard output gets the Notice severity and standard error gets Error.

runProcSilently :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m) => ProcessSpec -> m () Source #

Like runProc, but the child process' output and error streams get the Debug severity.

readProc :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) => ProcessSpec -> m Text Source #

A wrapper for readProcessAndLogOutput with sensible default verbosities: standard output gets the Debug severity and standard error gets Error.

The child process' output gets the Debug severity rather than the Notice severity because it is first and foremost /returned by this function/, so you can log it afterwards in a reasonable manner.