using System; using AntDesign.Docs.Build.CLI.Command; using AntDesign.Docs.Build.CLI.Utils; using Microsoft.Extensions.CommandLineUtils; using Microsoft.Extensions.DependencyInjection; namespace AntDesign.Docs.Build.CLI { internal class Program { private static int Main(string[] args) { return new Program().Run(args); } private readonly IServiceProvider _serviceProvider; public Program() { _serviceProvider = ConfigureServices(); } private int Run(string[] args) { try { var app = _serviceProvider.GetRequiredService(); return app.Execute(args); } catch (Exception e) { Console.WriteLine($"An error occurred. {e.Message}"); return 1; } } private IServiceProvider ConfigureServices() { var services = new ServiceCollection(); services.AddSingleton(); services.AddSingleton(p => p.GetRequiredService().Create()); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); return services.BuildServiceProvider(); } } }