pa-run-command-0.1.0.0: Helper functions for spawning subprocesses
Safe HaskellSafe-Inferred
LanguageGHC2021

RunCommand

Synopsis

Documentation

runCommand :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> m (ExitCode, ByteString) Source #

Given a a command, the executable and arguments, spawn the tool as subprocess and collect its stdout (stderr will go to our stderr).

Will strip the stdout of trailing newlines.

If the executable is not a path, it will be resolved via the PATH environment variable.

runCommandNoStdout :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> m ExitCode Source #

Given a a command, the executable and arguments, spawn the tool as subprocess and run it to conclusion.

If the executable is not a path, it will be resolved via the PATH environment variable.

runCommandWithStdin :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> ByteString -> m (ExitCode, ByteString) Source #

Like runCommand, but takes a Bytestring that provides the command with streamed input on stdin.

runCommandInteractiveExpect0 :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> m () Source #

Like runCommandExpect0, but don’t capture stdout, connect stdin and stdout to the command until it returns.

This is for interactive subcommands.

runCommandPipeToHandle :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> Handle -> m ExitCode Source #

Given a name of a command, the executable and arguments, spawn the tool as subprocess and pipe its stdout to the given Handle.

If the executable is not a path, it will be resolved via the PATH environment variable.

runCommandExpect0 :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> m ByteString Source #

Like runCommand but exit if the command returns a non-0 status.

runCommandExpect0NoStdout :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> m () Source #

Like runCommandNoStdout but exit if the command returns a non-0 status.

runCommandWithStdinExpect0 :: (MonadLogger m, MonadIO m) => FilePath -> [Text] -> ByteString -> m ByteString Source #

Like runCommandWithStdin but exit if the command returns a non-0 status.

checkStatus0 :: (MonadLogger m, MonadIO m) => FilePath -> ExitCode -> m () Source #

Check whether a command exited 0 or crash.

logCritical :: (HasCallStack, MonadLogger m, MonadIO m) => Text -> m b Source #

Log the message with logError, and call exitFailure.

prettyArgsForBash :: [Text] -> Text Source #

Pretty print a command line in a way that can be copied to bash.

simpleBashEscape :: Text -> Text Source #

Simple escaping for bash words. If they contain anything that’s not ascii chars and a bunch of often-used special characters, put the word in single quotes.