Can not register a Custom HelpProvider when using Microsoft.Extensions.DependencyInjection & Spectre.Console.Cli.Extensions.DependencyInjection. The default HelpProvider is used in stead of
the custom help provider.
My guess is, that the following line is overriding the HelpProvider.
and modified the test Should_Output_Custom_Help_When_Registered_By_Instance to use
[Fact]
[Expectation("Custom_Help_Registered_By_Instance")]
public Task Should_Output_Custom_Help_When_Registered_By_Instance()
{
var services = new ServiceCollection();
var registrar = new DependencyInjectionRegistrar(services);
// Given
var fixture = new CommandAppTester(registrar);
fixture.Configure(configurator =>
{
// Create the custom help provider
var helpProvider = new CustomHelpProvider(configurator.Settings, "1.0");
// Register the custom help provider instance
registrar.RegisterInstance(typeof(IHelpProvider), helpProvider);
configurator.SetApplicationName("myapp");
configurator.AddCommand<DogCommand>("dog");
});
// When
var result = fixture.Run();
// Then
return Verifier.Verify(result.Output);
}
Expected behavior
Custom HelpProvider should be used.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Information
Describe the bug
Can not register a Custom HelpProvider when using Microsoft.Extensions.DependencyInjection & Spectre.Console.Cli.Extensions.DependencyInjection. The default HelpProvider is used in stead of the custom help provider.
My guess is, that the following line is overriding the HelpProvider.
https://github.com/spectreconsole/spectre.console/blob/131b37fff858f8d5dd483ff369bb3d43a07c1e08/src/Spectre.Console.Cli/Internal/CommandExecutor.cs#L27
To Reproduce Steps to reproduce the behavior.
I installed these two nuget packages:
and modified the test Should_Output_Custom_Help_When_Registered_By_Instance to use
Expected behavior
Custom HelpProvider should be used.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.