Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom HelpProvider is being overridden by the default HelpProvider #1360

Closed
kedde opened this issue Nov 10, 2023 · 1 comment
Closed

Custom HelpProvider is being overridden by the default HelpProvider #1360

kedde opened this issue Nov 10, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@kedde
Copy link

kedde commented Nov 10, 2023

Information

  • OS: [eg Windows]
  • Version: git(main)
  • Terminal: [e.g Windows Terminal]

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.

_registrar.RegisterInstance(typeof(IHelpProvider), defaultHelpProvider);

To Reproduce
Steps to reproduce the behavior.

I installed these two nuget packages:

  • Microsoft.Extensions.DependencyInjection
  • Spectre.Console.Cli.Extensions.DependencyInjection

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.
billede

Additional context
Add any other context about the problem here.

@kedde kedde added bug Something isn't working needs triage labels Nov 10, 2023
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Nov 10, 2023
@nils-a
Copy link
Contributor

nils-a commented Nov 10, 2023

Closing as duplicate of #1313

@nils-a nils-a closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
@github-project-automation github-project-automation bot moved this from Todo 🕑 to Done 🚀 in Spectre Console Nov 10, 2023
@nils-a nils-a added duplicate This issue or pull request already exists and removed bug Something isn't working needs triage labels Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
Status: Done 🚀
Development

No branches or pull requests

2 participants