Skip to content

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

Closed
FrankRay78 wants to merge 5 commits into
spectreconsole:mainfrom
FrankRay78:702-Function-to-render-help-text
Closed

Can render command help and application version from inside a command#1133
FrankRay78 wants to merge 5 commits into
spectreconsole:mainfrom
FrankRay78:702-Function-to-render-help-text

Conversation

@FrankRay78

Copy link
Copy Markdown
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

Copy link
Copy Markdown
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

@patriksvensson patriksvensson left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function to render help text

2 participants