templating
templating copied to clipboard
Provide a better command example in case language option is used
Currently, when option is not valid for certain template language, example suggested does not specify language.
> dotnet new webapi -minimal -lang F#
Error: Invalid option(s):
-minimal
'-minimal' is not a valid option
For more information, run:
dotnet new webapi -h
Improve the example: when the language is specified, example should contain the language too, i.e. for the example above
dotnet new webapi -h -lang F#
When working on this another issue was found with .NET 7 (at least 7.0.100-preview.4.22252.9). dotnet new webapi -minimal -lang F#
throws the exception below.
Unable to cast object of type 'System.Boolean' to type 'System.String'.
at System.CommandLine.Binding.ArgumentConverter.GetValueOrDefault[T](ArgumentConversionResult result)
at Microsoft.TemplateEngine.Cli.Commands.TemplateOptionResult.FromParseResult(TemplateOption option, ParseResult parseResult)
at Microsoft.TemplateEngine.Cli.Commands.TemplateResult.FromParseResult(TemplateCommand templateCommand, ParseResult parseResult)
at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.CollectTemplateMatchInfo(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup)
at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.HandleNoTemplateFoundResult(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup, Reporter reporter)
at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.HandleTemplateInstantationAsync(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, ITelemetryLogger telemetryLogger, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup, CancellationToken cancellationToken)
at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.ExecuteIntAsync(InstantiateCommandArgs instantiateArgs, IEngineEnvironmentSettings environmentSettings, ITelemetryLogger telemetryLogger, InvocationContext context)
at Microsoft.TemplateEngine.Cli.Commands.BaseCommand`1.InvokeAsync(InvocationContext context)
Done in https://github.com/dotnet/sdk/pull/28135