diff --git a/src/System.CommandLine.Tests/ParserTests.MultipleArguments.cs b/src/System.CommandLine.Tests/ParserTests.MultipleArguments.cs index 331f8d651..f2e28b791 100644 --- a/src/System.CommandLine.Tests/ParserTests.MultipleArguments.cs +++ b/src/System.CommandLine.Tests/ParserTests.MultipleArguments.cs @@ -307,7 +307,7 @@ public void When_there_are_not_enough_tokens_for_all_arguments_then_the_correct_ var numberOfMissingArgs = result .Errors - .Count(e => e.Message == LocalizationResources.Instance.RequiredArgumentMissing(result.CommandResult)); + .Count(e => e.Message == LocalizationResources.Instance.RequiredArgumentMissing(command.Arguments.First(), result.CommandResult)); numberOfMissingArgs .Should() diff --git a/src/System.CommandLine.Tests/ParserTests.cs b/src/System.CommandLine.Tests/ParserTests.cs index 103a10f64..e36dba316 100644 --- a/src/System.CommandLine.Tests/ParserTests.cs +++ b/src/System.CommandLine.Tests/ParserTests.cs @@ -1401,7 +1401,7 @@ public void When_command_arguments_are_fewer_than_minimum_arity_then_an_error_is result.Errors .Select(e => e.Message) .Should() - .Contain(LocalizationResources.Instance.RequiredArgumentMissing(result.CommandResult)); + .Contain(LocalizationResources.Instance.RequiredArgumentMissing(command.Arguments.First(), result.CommandResult)); } [Fact] @@ -1489,7 +1489,7 @@ public void When_option_arguments_are_fewer_than_minimum_arity_then_an_error_is_ result.Errors .Select(e => e.Message) .Should() - .Contain(LocalizationResources.Instance.RequiredArgumentMissing(result.CommandResult.FindResultFor(option))); + .Contain(LocalizationResources.Instance.RequiredArgumentMissing(option.Argument, result.CommandResult.FindResultFor(option))); } [Fact] diff --git a/src/System.CommandLine.Tests/ResourceLocalizationTests.cs b/src/System.CommandLine.Tests/ResourceLocalizationTests.cs index a22841ec3..3a20a362f 100644 --- a/src/System.CommandLine.Tests/ResourceLocalizationTests.cs +++ b/src/System.CommandLine.Tests/ResourceLocalizationTests.cs @@ -62,7 +62,7 @@ public FakeLocalizationResources(string message) public override string FileDoesNotExist(string filePath) => message; - public override string RequiredArgumentMissing(SymbolResult symbolResult) => message; + public override string RequiredArgumentMissing(Argument argument, SymbolResult symbolResult) => message; public override string RequiredCommandWasNotProvided() => message; diff --git a/src/System.CommandLine.Tests/Utility/NonWindowsOnlyFactAttribute.cs b/src/System.CommandLine.Tests/Utility/NonWindowsOnlyFactAttribute.cs index 4b1e99d3e..201e300f1 100644 --- a/src/System.CommandLine.Tests/Utility/NonWindowsOnlyFactAttribute.cs +++ b/src/System.CommandLine.Tests/Utility/NonWindowsOnlyFactAttribute.cs @@ -10,7 +10,7 @@ public class NonWindowsOnlyFactAttribute : FactAttribute { public NonWindowsOnlyFactAttribute() { - if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + if (RuntimeEnvironment.OperatingSystemPlatform == Microsoft.DotNet.PlatformAbstractions.Platform.Windows) { Skip = "This test requires non-Windows to run"; } diff --git a/src/System.CommandLine.Tests/Utility/WindowsOnlyFactAttribute.cs b/src/System.CommandLine.Tests/Utility/WindowsOnlyFactAttribute.cs index ab389624a..3ed855770 100644 --- a/src/System.CommandLine.Tests/Utility/WindowsOnlyFactAttribute.cs +++ b/src/System.CommandLine.Tests/Utility/WindowsOnlyFactAttribute.cs @@ -10,7 +10,7 @@ public class WindowsOnlyFactAttribute : FactAttribute { public WindowsOnlyFactAttribute() { - if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) + if (RuntimeEnvironment.OperatingSystemPlatform != Microsoft.DotNet.PlatformAbstractions.Platform.Windows) { Skip = "This test requires Windows to run"; } diff --git a/src/System.CommandLine/ArgumentArity.cs b/src/System.CommandLine/ArgumentArity.cs index c0153fc86..8499a35dd 100644 --- a/src/System.CommandLine/ArgumentArity.cs +++ b/src/System.CommandLine/ArgumentArity.cs @@ -95,7 +95,7 @@ public override int GetHashCode() return ArgumentConversionResult.Failure( argument, - symbolResult.LocalizationResources.RequiredArgumentMissing(symbolResult), + symbolResult.LocalizationResources.RequiredArgumentMissing(argument, symbolResult), ArgumentConversionResultType.FailedMissingArgument); } diff --git a/src/System.CommandLine/Binding/ArgumentConverter.cs b/src/System.CommandLine/Binding/ArgumentConverter.cs index bc8683177..7cbb2a1bd 100644 --- a/src/System.CommandLine/Binding/ArgumentConverter.cs +++ b/src/System.CommandLine/Binding/ArgumentConverter.cs @@ -195,7 +195,7 @@ internal static ArgumentConversionResult ConvertIfNeeded( ArgumentConversionResultType.NoArgument when conversionResult.Argument.Arity.MinimumNumberOfValues > 0 => ArgumentConversionResult.Failure( conversionResult.Argument, - symbolResult.LocalizationResources.RequiredArgumentMissing(symbolResult), + symbolResult.LocalizationResources.RequiredArgumentMissing(conversionResult.Argument, symbolResult), ArgumentConversionResultType.FailedMissingArgument), _ => conversionResult diff --git a/src/System.CommandLine/LocalizationResources.cs b/src/System.CommandLine/LocalizationResources.cs index 0107ce06f..e80bed9f1 100644 --- a/src/System.CommandLine/LocalizationResources.cs +++ b/src/System.CommandLine/LocalizationResources.cs @@ -85,11 +85,25 @@ public virtual string InvalidCharactersInFileName(char invalidChar) => GetResourceString(Properties.Resources.InvalidCharactersInFileName, invalidChar); /// - /// Interpolates values into a localized string similar to Required argument missing for command: {0}. + /// Interpolates values into a localized string similar to + /// Required argument {0} missing for command: {1}. + /// or + /// Required argument missing for option: {0}. + /// + public virtual string RequiredArgumentMissing(Argument argument, SymbolResult symbolResult) => + symbolResult is CommandResult + ? GetResourceString(Properties.Resources.CommandRequiredArgumentMissing, argument.Name, symbolResult.Token().Value) + : GetResourceString(Properties.Resources.OptionRequiredArgumentMissing, symbolResult.Token().Value); + + /// + /// Interpolates values into a localized string similar to + /// Required argument {0} missing for command: {1}. + /// or + /// Required argument missing for option: {0}. /// public virtual string RequiredArgumentMissing(SymbolResult symbolResult) => symbolResult is CommandResult - ? GetResourceString(Properties.Resources.CommandRequiredArgumentMissing, symbolResult.Token().Value) + ? GetResourceString(Properties.Resources.CommandRequiredArgumentMissing, "(unknown)", symbolResult.Token().Value) : GetResourceString(Properties.Resources.OptionRequiredArgumentMissing, symbolResult.Token().Value); /// diff --git a/src/System.CommandLine/Properties/Resources.Designer.cs b/src/System.CommandLine/Properties/Resources.Designer.cs index ddb11c322..19ae3d952 100644 --- a/src/System.CommandLine/Properties/Resources.Designer.cs +++ b/src/System.CommandLine/Properties/Resources.Designer.cs @@ -115,7 +115,7 @@ internal static string CommandNoArgumentProvided { } /// - /// Looks up a localized string similar to Required argument missing for command: '{0}'.. + /// Looks up a localized string similar to Required argument '{0}' missing for command: '{1}'.. /// internal static string CommandRequiredArgumentMissing { get { diff --git a/src/System.CommandLine/Properties/Resources.resx b/src/System.CommandLine/Properties/Resources.resx index f0b101ebb..052fa30b8 100644 --- a/src/System.CommandLine/Properties/Resources.resx +++ b/src/System.CommandLine/Properties/Resources.resx @@ -148,7 +148,7 @@ Character not allowed in a path: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. Required argument missing for option: '{0}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.cs.xlf b/src/System.CommandLine/Properties/xlf/Resources.cs.xlf index 86c81955a..9ca5d0c7a 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.cs.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.cs.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.de.xlf b/src/System.CommandLine/Properties/xlf/Resources.de.xlf index e47d4bc1e..f125d18ef 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.de.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.de.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.es.xlf b/src/System.CommandLine/Properties/xlf/Resources.es.xlf index 2e85b00d2..3ef03ab2b 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.es.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.es.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.fr.xlf b/src/System.CommandLine/Properties/xlf/Resources.fr.xlf index e8afe2a03..99b3695a7 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.fr.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.fr.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.it.xlf b/src/System.CommandLine/Properties/xlf/Resources.it.xlf index 040135ce4..e4e3649be 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.it.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.it.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.ja.xlf b/src/System.CommandLine/Properties/xlf/Resources.ja.xlf index aa9c63dce..c4e10dc9c 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.ja.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.ja.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.ko.xlf b/src/System.CommandLine/Properties/xlf/Resources.ko.xlf index f5a4950dc..6b13db2c2 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.ko.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.ko.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.pl.xlf b/src/System.CommandLine/Properties/xlf/Resources.pl.xlf index b5cf7fd3f..2790f02c9 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.pl.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.pl.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.pt-BR.xlf b/src/System.CommandLine/Properties/xlf/Resources.pt-BR.xlf index 8f7e7af0d..87b0509f1 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.pt-BR.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.pt-BR.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.ru.xlf b/src/System.CommandLine/Properties/xlf/Resources.ru.xlf index 6a8b8128f..882cb876f 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.ru.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.ru.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.tr.xlf b/src/System.CommandLine/Properties/xlf/Resources.tr.xlf index c43d076b4..971288b3e 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.tr.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.tr.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.zh-Hans.xlf b/src/System.CommandLine/Properties/xlf/Resources.zh-Hans.xlf index ca955abeb..e80d1963a 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.zh-Hans.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.zh-Hans.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/Properties/xlf/Resources.zh-Hant.xlf b/src/System.CommandLine/Properties/xlf/Resources.zh-Hant.xlf index 3ceabfdb3..132a4da0f 100644 --- a/src/System.CommandLine/Properties/xlf/Resources.zh-Hant.xlf +++ b/src/System.CommandLine/Properties/xlf/Resources.zh-Hant.xlf @@ -33,8 +33,8 @@ - Required argument missing for command: '{0}'. - Required argument missing for command: '{0}'. + Required argument '{0}' missing for command: '{1}'. + Required argument '{0}' missing for command: '{1}'. diff --git a/src/System.CommandLine/System.CommandLine.csproj b/src/System.CommandLine/System.CommandLine.csproj index 05d284763..81a642d37 100644 --- a/src/System.CommandLine/System.CommandLine.csproj +++ b/src/System.CommandLine/System.CommandLine.csproj @@ -52,6 +52,7 @@ +