Skip to content

Commit

Permalink
Fix command line message (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Dec 5, 2023
1 parent 6a0895d commit 09890ee
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private bool ExtensionArgumentArityAreInvalid([NotNullWhen(true)] out string? er

ArgumentGuard.IsNotNull(_parseResult);

StringBuilder? stringBuilder = null;
StringBuilder stringBuilder = new();
foreach (IGrouping<string, OptionRecord> groupedOptions in _parseResult.Options.GroupBy(x => x.Option))
{
// getting the arguments count for an option.
Expand All @@ -229,22 +229,19 @@ private bool ExtensionArgumentArityAreInvalid([NotNullWhen(true)] out string? er

if (arity > commandLineOption.Arity.Max && commandLineOption.Arity.Max == 0)
{
stringBuilder ??= new();
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionExpectsNoArguments, optionName, extension.DisplayName, extension.Uid));
}
else if (arity < commandLineOption.Arity.Min)
{
stringBuilder ??= new();
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionExpectsNoArguments, optionName, extension.DisplayName, extension.Uid, commandLineOption.Arity.Min));
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionExpectsAtLeastArguments, optionName, extension.DisplayName, extension.Uid, commandLineOption.Arity.Min));
}
else if (arity > commandLineOption.Arity.Max)
{
stringBuilder ??= new();
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionExpectsNoArguments, optionName, extension.DisplayName, extension.Uid, commandLineOption.Arity.Max));
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineOptionExpectsAtMostArguments, optionName, extension.DisplayName, extension.Uid, commandLineOption.Arity.Max));
}
}

if (stringBuilder?.Length > 0)
if (stringBuilder.Length > 0)
{
error = stringBuilder.ToString();
return true;
Expand Down

0 comments on commit 09890ee

Please sign in to comment.