templating icon indicating copy to clipboard operation
templating copied to clipboard

Provide a better command example in case language option is used

Open vlada-shubina opened this issue 2 years ago • 1 comments

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#

vlada-shubina avatar Mar 21 '22 14:03 vlada-shubina

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)

GangWang01 avatar Sep 22 '22 08:09 GangWang01

Done in https://github.com/dotnet/sdk/pull/28135

GangWang01 avatar Oct 19 '22 01:10 GangWang01