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

[system-command-line] replaced host and telemetry logger parameters to NewCommand with delegates #4254

Merged

Conversation

vlada-shubina
Copy link
Member

@vlada-shubina vlada-shubina commented Jan 12, 2022

SDK (and also dotnet new3) needs to read some of the args to build the host.
In dotnet new3 this was solved via "pre-parsing" which was not ideal solution. Doing similar thing in SDK is not a way to go.

I have replaced host and telemetryLogger parameters with `Func<ParseResult, T> delegates to be able to create those once parsing is done. This way SDK may define additional options, add them to command and use them when creating hosts in this delegates.

Check the adaptation of dotnet new3 code to see how it works.

This revealed a problem when moving from dotnet new to instantiate command and manually adding global options to each BaseCommand. --debug: options were moved as GlobalOption on in NewCommand now. Also added tests for --debug: options.

fixes #3812
fixes #3053

@baronfel
Copy link
Member

That looks pretty straightforward to consume. It's essentially taking the same logic that's inside the Binder I made in my PR for the new Command, so it should be easy to extract that and be good to go 👍


commandResult
.Should()
.Fail()
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR: why do we fail when we try to list 0 templates? Sounds like list command executed successfully here.

src/Microsoft.TemplateEngine.Cli/NewCommandFactory.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@DavidKarlas DavidKarlas left a comment

Choose a reason for hiding this comment

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

Cool, after inspecting calls to CreateTelemetryLogger and CreateEnvironmentSettings looks like we dont need to do any caching...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants