Skip to content

Commit

Permalink
removed misleading error
Browse files Browse the repository at this point in the history
  • Loading branch information
vlada-shubina committed Sep 13, 2022
1 parent 90f5fe5 commit bc54599
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static List<InvalidTemplateOptionResult> GetInvalidOptions(IEnumerable<
//we need to process errors only for templates that match on language, type or baseline
IEnumerable<TemplateResult> templatesToAnalyze = templates.Where(template => template.IsTemplateMatch);

List<InvalidTemplateOptionResult> invalidOptionsList = new List<InvalidTemplateOptionResult>();
List<InvalidTemplateOptionResult> invalidOptionsList = new();

//collect the options with invalid names (unmatched tokens)
IEnumerable<InvalidTemplateOptionResult> unmatchedOptions = templatesToAnalyze.SelectMany(
Expand Down Expand Up @@ -61,7 +61,7 @@ internal static List<InvalidTemplateOptionResult> GetInvalidOptions(IEnumerable<

internal static List<TemplateResult> CollectTemplateMatchInfo(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup)
{
List<TemplateResult> matchInfos = new List<TemplateResult>();
List<TemplateResult> matchInfos = new();
foreach (CliTemplateInfo template in templateGroup.Templates)
{
if (ReparseForTemplate(args, environmentSettings, templatePackageManager, templateGroup, template)
Expand Down Expand Up @@ -91,7 +91,7 @@ private static string InvalidOptionsListToString(IEnumerable<InvalidTemplateOpti
templates = templates.Where(template => template.IsTemplateMatch);
}

StringBuilder invalidParamsErrorText = new StringBuilder(LocalizableStrings.InvalidCommandOptions);
StringBuilder invalidParamsErrorText = new(LocalizableStrings.InvalidCommandOptions);
foreach (InvalidTemplateOptionResult invalidParam in invalidParameterList)
{
invalidParamsErrorText.AppendLine();
Expand Down Expand Up @@ -143,7 +143,7 @@ private static NewCommandStatus HandleNoTemplateFoundResult(
}
else
{
var tokens = args.ParseResult.Tokens.Select(t => $"'{t.Value}'");
IEnumerable<string> tokens = args.ParseResult.Tokens.Select(t => $"'{t.Value}'");
reporter.WriteLine(string.Format(LocalizableStrings.Generic_Info_NoMatchingTemplates, string.Join(" ", tokens)).Bold().Red());
}
reporter.WriteLine();
Expand All @@ -168,7 +168,7 @@ private static void HandleNoMatchOnTemplateBaseOptions(IEnumerable<TemplateResul
Option<string> typeOption = SharedOptionsFactory.CreateTypeOption();
Option<string> baselineOption = SharedOptionsFactory.CreateBaselineOption();

Command reparseCommand = new Command("reparse-only")
Command reparseCommand = new("reparse-only")
{
languageOption,
typeOption,
Expand All @@ -181,11 +181,11 @@ private static void HandleNoMatchOnTemplateBaseOptions(IEnumerable<TemplateResul

ParseResult result = ParserFactory.CreateParser(reparseCommand).Parse(args.RemainingArguments ?? Array.Empty<string>());
string baseInputParameters = $"'{args.ShortName}'";
foreach (var option in new[] { languageOption, typeOption, baselineOption })
foreach (Option<string> option in new[] { languageOption, typeOption, baselineOption })
{
if (result.FindResultFor(option) is { } optionResult && optionResult.Token is { } token)
{
baseInputParameters = baseInputParameters + $", {token.Value}='{optionResult.GetValueOrDefault<string>()}'";
baseInputParameters += $", {token.Value}='{optionResult.GetValueOrDefault<string>()}'";
}
}

Expand All @@ -205,10 +205,6 @@ private static void HandleNoMatchOnTemplateBaseOptions(IEnumerable<TemplateResul
}

Reporter.Error.WriteLine();

WriteListCommandExample(args, Reporter.Error);
WriteSearchCommandExample(args, Reporter.Error);
Reporter.Error.WriteLine();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
No templates found matching: 'console', --language='D#'.
Allowed values for '--language' option are: 'C#', 'F#', 'VB'.

To list installed templates similar to 'console', run:
dotnet new list console
To search for the templates on NuGet.org, run:
dotnet new search console


For details on the exit code, refer to https://aka.ms/templating-exit-codes#103
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
No templates found matching: 'console', --type='item'.
Allowed values for '--type' option are: 'project'.

To list installed templates similar to 'console', run:
dotnet new list console
To search for the templates on NuGet.org, run:
dotnet new search console


For details on the exit code, refer to https://aka.ms/templating-exit-codes#103

0 comments on commit bc54599

Please sign in to comment.