mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
21 lines
712 B
C#
21 lines
712 B
C#
using CliFx;
|
|
using CliFx.Demo.Domain;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
return await new CliApplicationBuilder()
|
|
.SetDescription("Demo application showcasing CliFx features.")
|
|
.AddCommandsFromThisAssembly()
|
|
.UseTypeActivator(commandTypes =>
|
|
{
|
|
// We use Microsoft.Extensions.DependencyInjection for injecting dependencies in commands
|
|
var services = new ServiceCollection();
|
|
services.AddSingleton<LibraryProvider>();
|
|
|
|
// Register all commands as transient services
|
|
foreach (var commandType in commandTypes)
|
|
services.AddTransient(commandType);
|
|
|
|
return services.BuildServiceProvider();
|
|
})
|
|
.Build()
|
|
.RunAsync(); |