public static CommandLineResult CommandLine(params string[] args) { var handler = new CommandLineHandler(); var argsList = new List <string>(); argsList.Add(Environment.CurrentDirectory); argsList.AddRange(args); var stringWriter = new StringWriter(); var originalOutput = Console.Out; Console.SetOut(stringWriter); handler.HandleCommandLine(argsList.ToArray()); return(new CommandLineResult { ErrorCount = handler.ErrorCount, WarningCount = handler.WarningCount, Output = stringWriter.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) }); }