public static int Main(string[] args) { var options = new Options(); int retCode = 1; if (CommandLineParser.Default.ParseArguments(args, options)) { if (options.SourceFiles.Count < 1 || options.SourceFiles.Count > 3) { Console.Error.WriteLine(options.GetUsage()); return retCode; } prjFile = options.SourceFiles[0]; try { if (options.ExtractHeightmap) { retCode = DoImageExtraction(options); } else { retCode = DoDefault(options); } } catch (Exception e) { if (e is ArgumentException || e is NotSupportedException || e is SecurityException || e is IOException || e is UnauthorizedAccessException) { Console.Error.Write("Error: "); Console.Error.WriteLine(e.Message); return 2; } else { // Unexpected Exception -> Crash throw; } } } return retCode; }