static int Main(string[] args) { var outputWriter = Console.Out; //new StreamWriter(Console.OpenStandardError()); TextWriter errorWriter = new ColoredWriter(Console.Error, ConsoleColor.Red); var warningWriter = new ColoredWriter(Console.Out, ConsoleColor.Yellow); var logWriter = new ColoredWriter(Console.Out, ConsoleColor.White); CommandContext commandContext = null; try { commandContext = CommandContext.Parse(args); if (commandContext.AnySwitch(DuplexErrorOutputSwitchName)) { var errorStdOutWriter = new ColoredWriter(Console.Out, ConsoleColor.Red); var errorErrOutWriter = Console.Error; errorWriter = new MultiStreamWriter(errorStdOutWriter, errorErrOutWriter); } Platforms.AddPlatform(new UnixBashPlatform()); foreach (var command in AvailableCommands) { if (command.CanHandle(commandContext)) { if (commandContext.AnySwitch("help") && command != HelpCommand) { HelpCommand.ShowHelp(outputWriter, command); return((int)ResultCodes.Successful); } return((int)command.Execute(outputWriter, errorWriter, warningWriter, logWriter, commandContext)); } } } catch (Exception ex) { if (commandContext == null) { errorWriter.WriteLine(ex.Message); return((int)ResultCodes.Failure); } Action <TextWriter, TextWriter, TextWriter, TextWriter, Exception> writer = null; if (commandContext.AnySwitch("verbose")) { writer = WriteCompilerDebugInfo; } else if (commandContext.AnySwitch(CompatibleOutputSwitchName)) { writer = WriteCleanErrorInfo; } if (writer == null) { errorWriter.WriteLine(ex.Message); } else { writer(outputWriter, errorWriter, warningWriter, logWriter, ex); } return((int)ResultCodes.Failure); } errorWriter.WriteLine(DesignGuidelines.ErrorOutputHead + " Invalid command passed. ({0})", args.Length > 0 ? args[0] : "null"); return((int)ResultCodes.Failure); }