Program.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Globalization; 7 using System.Text; 8 9 using ImageResizer.Cli; 10 using ManagedCommon; 11 12 namespace ImageResizerCLI; 13 14 internal static class Program 15 { 16 private static int Main(string[] args) 17 { 18 try 19 { 20 string appLanguage = LanguageHelper.LoadLanguage(); 21 if (!string.IsNullOrEmpty(appLanguage)) 22 { 23 System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(appLanguage); 24 } 25 } 26 catch (CultureNotFoundException) 27 { 28 // Ignore invalid culture and fall back to default. 29 } 30 31 Console.InputEncoding = Encoding.Unicode; 32 33 // Initialize logger to file (same as other modules) 34 CliLogger.Initialize("\\Image Resizer\\CLI"); 35 CliLogger.Info($"ImageResizerCLI started with {args.Length} argument(s)"); 36 37 try 38 { 39 var executor = new ImageResizerCliExecutor(); 40 return executor.Run(args); 41 } 42 catch (Exception ex) 43 { 44 CliLogger.Error($"Unhandled exception: {ex.Message}"); 45 CliLogger.Error($"Stack trace: {ex.StackTrace}"); 46 Console.Error.WriteLine($"Fatal error: {ex.Message}"); 47 return 1; 48 } 49 } 50 }