Handle Standard IO streams
masterMedallionShell captures standard error and standard output by default in the CommandResult. You can access these via result.StandardOutput and result.StandardError after the command completes.
Consuming output as a merged stream
To process stdout and stderr as a single interleaved stream of lines (similar to a console), use GetOutputAndErrorLines().
Direct stream interaction
You can interact with Command.StandardInput, Command.StandardOutput, and Command.StandardError directly. These expose TextWriter/TextReader for text and BaseStream for raw bytes.
Warning: Any content you read directly from these streams will not be included in the result.StandardOutput or result.StandardError properties. The result properties only store content that has not been consumed by other mechanisms.
// 1. Accessing captured output from result
var command = Command.Run("ls");
var result = await command.Task;
Console.WriteLine(result.StandardOutput);
// 2. Consuming merged lines
foreach (var line in command.GetOutputAndErrorLines())
{
Console.WriteLine(line);
}
// 3. Direct stream interaction (Text and Bytes)
command.StandardInput.Write("some text");
command.StandardInput.BaseStream.Write(new byte[100]);
string line = command.StandardOutput.ReadLine();