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

Creating new HelpProvider does not work (unresolved symbols) #1356

Closed
sebbarg opened this issue Nov 6, 2023 · 2 comments
Closed

Creating new HelpProvider does not work (unresolved symbols) #1356

sebbarg opened this issue Nov 6, 2023 · 2 comments
Labels
bug Something isn't working needs triage

Comments

@sebbarg
Copy link

sebbarg commented Nov 6, 2023

Information

  • OS: [MacOS]
  • Version: [e.g. 0.47.0]
  • Terminal: N/A

Describe the bug
Below program tries to create a new HelpProvider like described here: https://spectreconsole.net/cli/command-help and here: https://github.com/spectreconsole/spectre.console/tree/main/examples/Cli/Help

There are numerous compile errors because of unresolved symbols, e.g. config.SetHelpProvider and HelpProvider.

The example code is bringing in a shared library, that only seems to exist in the examples project.

Am I missing something??

using Spectre.Console;
using Spectre.Console.Cli;
using Spectre.Console.Rendering;

namespace Help;

//

internal class CustomHelpProvider : HelpProvider
{
    public CustomHelpProvider(ICommandAppSettings settings)
        : base(settings)
    {
    }

    public override IEnumerable<IRenderable> GetHeader(ICommandModel model, ICommandInfo? command)
    {
        return new[]
        {
            new Text("--------------------------------------"), Text.NewLine,
            new Text("---      CUSTOM HELP PROVIDER      ---"), Text.NewLine,
            new Text("--------------------------------------"), Text.NewLine,
            Text.NewLine,
        };
    }
}

//

public sealed class DefaultCommand : Command
{
    private IAnsiConsole _console;

    public DefaultCommand(IAnsiConsole console)
    {
        _console = console;
    }

    public override int Execute(CommandContext context)
    {
        _console.WriteLine("Hello world");
        return 0;
    }
}

//

public static class Program
{
    public static int Main(string[] args)
    {
        var app = new CommandApp<DefaultCommand>();

        app.Configure(config =>
        {
            // Register the custom help provider
            config.SetHelpProvider(new CustomHelpProvider(config.Settings));
        });

        return app.Run(args);
    }
}
@sebbarg sebbarg added bug Something isn't working needs triage labels Nov 6, 2023
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Nov 6, 2023
@sebbarg
Copy link
Author

sebbarg commented Nov 6, 2023

Project file:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="Spectre.Console" Version="0.47.0" />
      <PackageReference Include="Spectre.Console.Cli" Version="0.47.0" />
    </ItemGroup>

</Project>

@sebbarg
Copy link
Author

sebbarg commented Nov 6, 2023

Ach... upgrading to pre-release 0.47.1-preview.0.27 seems to fix the problem. Closing.

@sebbarg sebbarg closed this as completed Nov 6, 2023
@github-project-automation github-project-automation bot moved this from Todo 🕑 to Done 🚀 in Spectre Console Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: Done 🚀
Development

No branches or pull requests

1 participant