Example #1
0
        /// <summary>
        /// Run the command whos name is the first argument with the remaining arguments provided to the command
        /// as needed.
        /// </summary>
        public void Run(string[] arguments, TextWriter mapstdout, TextWriter mapstderr, TextReader mapstdin)
        {
            TextWriter stdout = ConsoleOutput.Capture(mapstdout);
            TextWriter stderr = ConsoleError.Capture(mapstderr);
            TextReader stdin  = ConsoleInput.Capture(mapstdin);

            try
            {
                GetHead().Next(arguments ?? new string[0]);
            }
            finally
            {
                ConsoleOutput.Restore(mapstdout, stdout);
                ConsoleError.Restore(mapstderr, stderr);
                ConsoleInput.Restore(mapstdin, stdin);
            }
        }
Example #2
0
 /// <summary>
 /// Sets the error stream.
 /// </summary>
 /// <param name="reader">The reader.</param>
 public void SetErrorStream(System.IO.StreamReader reader)
 {
     ErrorStream = reader;
     new Thread(new ThreadStart(delegate {
         while (IsRunning)
         {
             while (!ErrorStream.EndOfStream)
             {
                 string line   = ErrorStream.ReadLine( );
                 OutputingData = true;
                 if (!string.IsNullOrEmpty(line) && ConsoleError != null)
                 {
                     ConsoleError.WriteLine(line);
                 }
             }
         }
     })).Start( );
 }
Example #3
0
 public void Dispose()
 {
     ConsoleInput.Dispose();
     ConsoleOutput.Dispose();
     ConsoleError.Dispose();
 }
Example #4
0
 public string GetErrorText()
 {
     return(ConsoleError.ToString());
 }