public static void Main(string[] args) { Options commandLineOptions = new Options(); ICommandLineParser commandParser = new CommandLineParser(); if (commandParser.ParseArguments(args, commandLineOptions, Console.Error)) { if (ValidateOptions(commandLineOptions)) { try { TaskProcessor infoTask = new TaskProcessor(); infoTask.ProcessTask(commandLineOptions); } catch (Exception ex) { StringBuilder errorMessage = new StringBuilder(); errorMessage.AppendLine(messageUnexpectedError); if (commandLineOptions.debugMessages) { errorMessage.AppendFormat(messageUnhandledException, ex.ToString(), ex.Message, ex.StackTrace); } System.Console.Error.WriteLine(errorMessage.ToString()); Environment.ExitCode = 1; } } } else { // Command line params could not be parsed, // or help was requested Environment.ExitCode = -1; } }