|
PeanutButter
|
Classes | |
| class | UnstartedProcessIO |
| Represents an unstarted process-io instance. More... | |
Public Member Functions | |||||||
| 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. | |||||||
Static Public Member Functions | |
| 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 | |
| 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 | |
| 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. | |
| PeanutButter.Utils.ProcessIO.ProcessIO | ( | string | filename, |
| params string[] | arguments ) |
Run the provided command, pipe output as it streams.
| filename | app to run |
| arguments | args for that app |
| void PeanutButter.Utils.ProcessIO.Dispose | ( | ) |
Kills the process if it hasn't finished yet.
|
static |
Sets up ProcessIO to run within the provided folder. Usage: using var io = ProcessIO.In("/path/to/folder").Start("cmd", "arg1", "arg2")
| workingDirectory |
| void PeanutButter.Utils.ProcessIO.Kill | ( | ) |
Kill the underlying process.
Implements PeanutButter.Utils.IProcessIO.
|
static |
Quotes a string if it's necessary:
| str |
|
static |
Starts a ProcessIO instance for the given filename and args in the current working directory.
| outputMode | |
| stderrReceiver | |
| filename | |
| args | |
| stdoutReceiver |
|
static |
Starts a ProcessIO instance for the given filename and args in the current working directory.
| filename | |
| args |
| int PeanutButter.Utils.ProcessIO.WaitForExit | ( | ) |
Wait for the process to exit and return the exit code.
Implements PeanutButter.Utils.IProcessIO.
| int? PeanutButter.Utils.ProcessIO.WaitForExit | ( | int | timeoutMs | ) |
Wait up to the timeout for the process to exit and return the exit code, if available.
| timeoutMilliseconds |
Implements PeanutButter.Utils.IProcessIO.
| bool PeanutButter.Utils.ProcessIO.WaitForOutput | ( | StandardIo | io, |
| Func< string, bool > | matcher ) |
Waits for some output to be emitted from the process.
| io | |
| matcher |
Implements PeanutButter.Utils.IProcessIO.
| bool PeanutButter.Utils.ProcessIO.WaitForOutput | ( | StandardIo | io, |
| Func< string, bool > | matcher, | ||
| int | timeoutMilliseconds ) |
Waits for some output to be emitted from the process.
| io | |
| matcher | |
| timeoutMilliseconds |
Implements PeanutButter.Utils.IProcessIO.
|
static |
Sets up a bunch of environment variables for the new process.
| environment |
|
static |
Sets up for the new process to use the provided environment variable.
| name | |
| value |
|
static |
|
static |
Start the process with the eventing output mode, specifying a stderr receiver.
| receiver |
|
static |
Start the process with the eventing output mode, specifying a stdout receiver.
| receiver |
|
get |
A copy of the commandline arguments to that program.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Renders the commandline used to start this process.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Provides access to the exit code of the process, waiting for it to complete if necessary.
Implements PeanutButter.Utils.IProcessIO.
|
get |
The program started by this ProcessIO.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Flag: true when the process has exited (or couldn't start up)
Implements PeanutButter.Utils.IProcessIO.
|
getset |
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.
Implements PeanutButter.Utils.IProcessIO.
|
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.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Access to the underlying Process.
Implements PeanutButter.Utils.IProcessIO.
|
get |
The process id.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Read lines from stderr until the process exits.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Read the lines captured thus far from stderr - does not wait for the process to complete.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Direct access to the StandardInput on the process.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Read lines from stdout until the process exits.
Implements PeanutButter.Utils.IProcessIO.
|
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.
Implements PeanutButter.Utils.IProcessIO.
|
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.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Read the lines captured thus far from stdout - does not wait for the process to complete.
Implements PeanutButter.Utils.IProcessIO.
|
get |
True if the process started properly.
Implements PeanutButter.Utils.IProcessIO.
|
get |
Set if the process didn't start properly, to the exception thrown.
Implements PeanutButter.Utils.IProcessIO.
|
get |
The working directory in which the process was launched.
Implements PeanutButter.Utils.IProcessIO.