PeanutButter
|
Represents an unstarted process-io instance. More...
Public Member Functions | |||||||
new IProcessIO | Start (string filename, params string[] arguments) | ||||||
Starts the process in the previously provided working directory.
| |||||||
new IUnstartedProcessIO | WithEnvironmentVariable (string name, string value) | ||||||
Adds another environment variable to the process startup environment.
| |||||||
new IUnstartedProcessIO | In (string workingDirectory) | ||||||
Set the working directory for the process; use if you started the fluent chain with WithEnvironmentVariable
| |||||||
new IUnstartedProcessIO | WithEnvironment (IDictionary< string, string > env) | ||||||
Establish a set of environment variables for the process.
| |||||||
new IUnstartedProcessIO | WithStdOutReceiver (Action< string > receiver) | ||||||
Starts the process with an action to receive stdout data as it streams, instead of buffering to a collection.
| |||||||
new IUnstartedProcessIO | WithStdErrReceiver (Action< string > receiver) | ||||||
Starts the process with an action to receive stderr data as it streams, instead of buffering to a collection.
| |||||||
new IUnstartedProcessIO | WithPassthroughIo () | ||||||
Allows stdout and stderr to be passed through to the calling shell, effectively shorthand for .WithStdOutReceiver(Console.WriteLine) .WithStdErrReceiver(Console.Error.WriteLine)
| |||||||
Public Member Functions inherited from PeanutButter.Utils.ProcessIO | |||||||
ProcessIO (string filename, params string[] arguments) | |||||||
Run the provided command, pipe output as it streams. | |||||||
int | WaitForExit () | ||||||
Wait for the process to exit and return the exit code.
| |||||||
int? | WaitForExit (int timeoutMs) | ||||||
Wait up to the timeout for the process to exit and return the exit code, if available.
| |||||||
void | Kill () | ||||||
Kill the underlying process. | |||||||
bool | WaitForOutput (StandardIo io, Func< string, bool > matcher) | ||||||
Waits for some output to be emitted from the process.
| |||||||
bool | WaitForOutput (StandardIo io, Func< string, bool > matcher, int timeoutMilliseconds) | ||||||
Waits for some output to be emitted from the process.
| |||||||
void | Dispose () | ||||||
Kills the process if it hasn't finished yet. |
Additional Inherited Members | |
Static Public Member Functions inherited from PeanutButter.Utils.ProcessIO | |
static UnstartedProcessIO | In (string workingDirectory) |
Sets up ProcessIO to run within the provided folder. Usage: using var io = ProcessIO.In("/path/to/folder").Start("cmd", "arg1", "arg2") | |
static IProcessIO | Start (string filename, params string[] args) |
Starts a ProcessIO instance for the given filename and args in the current working directory. | |
static IProcessIO | Start (OutputModes outputMode, IEnumerable< Action< string > > stdoutReceiver, IEnumerable< Action< string > > stderrReceiver, string filename, params string[] args) |
Starts a ProcessIO instance for the given filename and args in the current working directory. | |
static string | QuoteIfNecessary (string str) |
Quotes a string if it's necessary: | |
static IUnstartedProcessIO | WithEnvironmentVariable (string name, string value) |
Sets up for the new process to use the provided environment variable. | |
static IUnstartedProcessIO | WithEnvironment (IDictionary< string, string > environment) |
Sets up a bunch of environment variables for the new process. | |
static IUnstartedProcessIO | WithStdOutReceiver (Action< string > receiver) |
Start the process with the eventing output mode, specifying a stdout receiver. | |
static IUnstartedProcessIO | WithPassthroughIo () |
static IUnstartedProcessIO | WithStdErrReceiver (Action< string > receiver) |
Start the process with the eventing output mode, specifying a stderr receiver. | |
Properties inherited from PeanutButter.Utils.ProcessIO | |
string | Filename [get] |
The program started by this ProcessIO. | |
string[] | Arguments [get] |
A copy of the commandline arguments to that program. | |
string | WorkingDirectory [get] |
The working directory in which the process was launched. | |
int | MaxBufferLines = int.MaxValue [get, set] |
IO is buffered internally so you can start listening to it whenever you want, from the start - however, when the target process produces a lot of IO (eg mysqldump), it's reasonable to enforce a history limit to reduce memory usage. | |
string | Commandline [get] |
Renders the commandline used to start this process. | |
int | ProcessId [get] |
The process id. | |
bool | Started [get] |
True if the process started properly. | |
Exception | StartException [get] |
Set if the process didn't start properly, to the exception thrown. | |
Process | Process [get] |
Access to the underlying Process. | |
OutputModes | OutputMode [get] |
Which output mode to use (buffered collections or events). Note that changes to this property will not be observed after the process has started. | |
int | ExitCode [get] |
Provides access to the exit code of the process, waiting for it to complete if necessary. | |
IEnumerable< string > | StandardOutput [get] |
Read lines from stdout until the process exits. | |
IEnumerable< string > | StandardOutputSnapshot [get] |
Read the lines captured thus far from stdout - does not wait for the process to complete. | |
IEnumerable< string > | StandardError [get] |
Read lines from stderr until the process exits. | |
IEnumerable< string > | StandardErrorSnapshot [get] |
Read the lines captured thus far from stderr - does not wait for the process to complete. | |
IEnumerable< string > | StandardOutputAndErrorInterleaved [get] |
Read the lines from stderr and stdout (until the process exits), interleaved (mostly in order, though some minor out-of-order situations can occur between stderr and stdout if there is rapid output on both because of the async io handlers for dotnet Process objects. | |
IEnumerable< string > | StandardOutputAndErrorInterleavedSnapshot [get] |
Read the lines captured thus far from stderr and stdout, interleaved (mostly in order, though some minor out-of-order situations can occur between stderr and stdout if there is rapid output on both because of the async io handlers for dotnet Process objects.
| |
StreamWriter | StandardInput [get] |
Direct access to the StandardInput on the process. | |
bool | HasExited [get] |
Flag: true when the process has exited (or couldn't start up) | |
Events inherited from PeanutButter.Utils.ProcessIO | |
EventHandler< string > | OnStdOut |
EventHandler< string > | OnStdErr |
Events inherited from PeanutButter.Utils.IProcessIO | |
EventHandler< string > | OnStdOut |
Raised when receiving data on stdout from the process. | |
EventHandler< string > | OnStdErr |
Raised when receiving data on stderr from the process. |
Represents an unstarted process-io instance.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.In | ( | string | workingDirectory | ) |
Set the working directory for the process; use if you started the fluent chain with WithEnvironmentVariable
workingDirectory |
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.Start | ( | string | filename, |
params string[] | arguments ) |
Starts the process in the previously provided working directory.
filename | |
arguments |
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.WithEnvironment | ( | IDictionary< string, string > | env | ) |
Establish a set of environment variables for the process.
env |
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.WithEnvironmentVariable | ( | string | name, |
string | value ) |
Adds another environment variable to the process startup environment.
name | |
value |
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.WithPassthroughIo | ( | ) |
Allows stdout and stderr to be passed through to the calling shell, effectively shorthand for .WithStdOutReceiver(Console.WriteLine) .WithStdErrReceiver(Console.Error.WriteLine)
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.WithStdErrReceiver | ( | Action< string > | receiver | ) |
Starts the process with an action to receive stderr data as it streams, instead of buffering to a collection.
receiver |
Implements PeanutButter.Utils.IUnstartedProcessIO.
new IUnstartedProcessIO PeanutButter.Utils.ProcessIO.UnstartedProcessIO.WithStdOutReceiver | ( | Action< string > | receiver | ) |
Starts the process with an action to receive stdout data as it streams, instead of buffering to a collection.
receiver |
Implements PeanutButter.Utils.IUnstartedProcessIO.