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

Can render command help and application version from inside a command #1133

Conversation

FrankRay78
Copy link
Contributor

Fully implements #702


Also, starts to introduce a clean entry point for allowing spectre.console users (in the future) to override the default HelpWriter with their own implementation, here is where the DI will need to happen, Spectre.Console.Cli.CommandExecutor line 54:

var helpProvider = new HelpWriter(model, parsedResult, configuration.Settings.ShowOptionDefaultValues) as IHelpProvider;

@FrankRay78 FrankRay78 requested a review from a team January 13, 2023 14:35
@FrankRay78 FrankRay78 self-assigned this Jan 13, 2023
@FrankRay78 FrankRay78 linked an issue Jan 13, 2023 that may be closed by this pull request
@FrankRay78 FrankRay78 added the area-CLI Command-Line Interface label May 13, 2023
@FrankRay78
Copy link
Contributor Author

@microsoft-github-policy-service agree

@FrankRay78 FrankRay78 changed the base branch from main to renovate/dotnet-sdk-7.x May 14, 2023 15:09
@FrankRay78 FrankRay78 changed the base branch from renovate/dotnet-sdk-7.x to main May 14, 2023 15:10
Copy link
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking about this for a while.

Wouldn't it be better if we exposed an interface IHelpWriter (like you have in this PR) that contains a method to create the help text from a simplified version of CommandModel?

public interface IHelpProvider
{
    IEnumerable<IRenderable> GetHelp(SomeSimplifiedCommandModel model);
}

This way, people could design their help text however they want.

@FrankRay78
Copy link
Contributor Author

I've been thinking about this as well, and I agree @patriksvensson .

It also starts to tie in with this #1093, which is about separating out initialisation/allowing users to register their own concrete implementations in the DI factory ahead of command parsing etc.

I'll have a go at updating this PR and resubmit.

@FrankRay78
Copy link
Contributor Author

FYI. I'm going to start reworking this PR @patriksvensson. Assuming the help writer improvements in #1252 are generally on point, I'm going to branch from that as a better starting point than main.

@FrankRay78
Copy link
Contributor Author

Closing, as superseded by #1259

@FrankRay78 FrankRay78 closed this Jul 19, 2023
@FrankRay78 FrankRay78 deleted the 702-Function-to-render-help-text branch September 21, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CLI Command-Line Interface
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Function to render help text
2 participants