Closed adambajguz closed 4 years ago
Yes, you would do it like this:
var services = new ServiceCollection();
services.AddSingleton<IConsole>(new SystemConsole()); // or `new VirtualConsole();`, depending on what you need
var serviceProvider = services.BuildServiceProvider();
// ...
var console = serviceProvider.GetService<IConsole>();
var cli = new CliApplicationBuilder()
.AddCommandsFromThisAssembly()
.UseConsole(console) // make sure CliFx is using the same instance of IConsole
.Build()
Thanks, I think this can be added to the README.
Is it possible to inject IConsole instance to some service using Microsoft.Extensions.DependencyInjection?