mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
25 lines
785 B
C#
25 lines
785 B
C#
using CliFx;
|
|
using CliFx.Demo.Commands;
|
|
using CliFx.Demo.Domain;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
// We use Microsoft.Extensions.DependencyInjection for injecting dependencies in commands
|
|
var services = new ServiceCollection();
|
|
|
|
// Register services
|
|
services.AddSingleton<LibraryProvider>();
|
|
|
|
// Register commands
|
|
services.AddTransient<BookCommand>();
|
|
services.AddTransient<BookAddCommand>();
|
|
services.AddTransient<BookRemoveCommand>();
|
|
services.AddTransient<BookListCommand>();
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
return await new CliApplicationBuilder()
|
|
.SetDescription("Demo application showcasing CliFx features.")
|
|
.AddCommandsFromThisAssembly()
|
|
.UseTypeActivator(serviceProvider.GetRequiredService)
|
|
.Build()
|
|
.RunAsync(); |