From 5af77cb037667051b64ae8258ab302d13658ad64 Mon Sep 17 00:00:00 2001 From: Ignacio Calvo Date: Tue, 8 Feb 2022 21:19:17 +0100 Subject: [PATCH] Fixed some typos in exception messages --- src/Cocona.Core/Command/CoconaCommandProvider.cs | 12 ++++++------ src/Cocona.Core/Command/CommandCollection.cs | 2 +- .../Command/Dispatcher/CoconaCommandMatcher.cs | 2 +- .../GetCommandCollectionFromCommandDataTest.cs | 2 +- .../Integration/BuildAppCommandsWithBuilderTest.cs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Cocona.Core/Command/CoconaCommandProvider.cs b/src/Cocona.Core/Command/CoconaCommandProvider.cs index 1214d7f..e0bd12c 100644 --- a/src/Cocona.Core/Command/CoconaCommandProvider.cs +++ b/src/Cocona.Core/Command/CoconaCommandProvider.cs @@ -162,7 +162,7 @@ void AddCommand(CommandDescriptor command) { if (commandNames.Contains(command.Name)) { - throw new CoconaException($"Command '{command.Name}' has already exists. (Method: {command.Method.Name})"); + throw new CoconaException($"Command '{command.Name}' already exists. (Method: {command.Method.Name})"); } commandNames.Add(command.Name); @@ -172,7 +172,7 @@ void AddCommand(CommandDescriptor command) { if (commandNames.Contains(alias)) { - throw new CoconaException($"Command alias '{alias}' has already exists in commands. (Method: {command.Method.Name})"); + throw new CoconaException($"Command alias '{alias}' already exists in commands. (Method: {command.Method.Name})"); } commandNames.Add(alias); } @@ -700,9 +700,9 @@ public void AddOption(CommandParameterAttributeSet attrSet, Type type, string na var optionDescriptor = CreateOption(attrSet, type, name, defaultValue); if (_allOptions.ContainsKey(optionDescriptor.Name)) - throw new CoconaException($"Option '{optionDescriptor.Name}' is already exists."); + throw new CoconaException($"Option '{optionDescriptor.Name}' already exists."); if (_allOptionShortNames.Count != 0 && optionDescriptor.ShortName.Count != 0 && _allOptionShortNames.IsSupersetOf(optionDescriptor.ShortName)) - throw new CoconaException($"Short name option '{string.Join(",", optionDescriptor.ShortName)}' is already exists."); + throw new CoconaException($"Short name option '{string.Join(",", optionDescriptor.ShortName)}' already exists."); _allOptions.Add(optionDescriptor.Name, optionDescriptor); _allOptionShortNames.UnionWith(optionDescriptor.ShortName); @@ -789,9 +789,9 @@ public void AddOption(CommandParameterAttributeSet attrSet, Type type, string na var optionDescriptor = _parent.CreateOption(attrSet, type, name, defaultValue); if (_parent._allOptions.ContainsKey(optionDescriptor.Name)) - throw new CoconaException($"Option '{optionDescriptor.Name}' is already exists."); + throw new CoconaException($"Option '{optionDescriptor.Name}' already exists."); if (_parent._allOptionShortNames.Count != 0 && optionDescriptor.ShortName.Count != 0 && _parent._allOptionShortNames.IsSupersetOf(optionDescriptor.ShortName)) - throw new CoconaException($"Short name option '{string.Join(",", optionDescriptor.ShortName)}' is already exists."); + throw new CoconaException($"Short name option '{string.Join(",", optionDescriptor.ShortName)}' already exists."); _parent._allOptions.Add(optionDescriptor.Name, optionDescriptor); _parent._allOptionShortNames.UnionWith(optionDescriptor.ShortName); diff --git a/src/Cocona.Core/Command/CommandCollection.cs b/src/Cocona.Core/Command/CommandCollection.cs index 746992c..e22a3fb 100644 --- a/src/Cocona.Core/Command/CommandCollection.cs +++ b/src/Cocona.Core/Command/CommandCollection.cs @@ -22,7 +22,7 @@ public CommandCollection(IReadOnlyList commands) { if (Primary != null) { - throw new CoconaException($"The commands contains more then one primary command. A primary command must be only one.: {string.Join(", ", commands.Where(x => x.IsPrimaryCommand).Select(x => x.Name))}"); + throw new CoconaException($"The commands contain more than one primary command. A primary command must be unique.: {string.Join(", ", commands.Where(x => x.IsPrimaryCommand).Select(x => x.Name))}"); } Primary = command; } diff --git a/src/Cocona.Core/Command/Dispatcher/CoconaCommandMatcher.cs b/src/Cocona.Core/Command/Dispatcher/CoconaCommandMatcher.cs index 2a08984..16f31a6 100644 --- a/src/Cocona.Core/Command/Dispatcher/CoconaCommandMatcher.cs +++ b/src/Cocona.Core/Command/Dispatcher/CoconaCommandMatcher.cs @@ -38,7 +38,7 @@ public CommandDescriptor ResolveOverload(CommandDescriptor command, ParsedComman { if ((overloadCommand.Value == null) || (value.Value != null && overloadCommand.Comparer.Equals(value.Value, overloadCommand.Value))) { - if (resolvedCommand != null) throw new CoconaException($"Command '{command.Name}' and option '{overloadCommand.Option}' has option overloads more than one."); + if (resolvedCommand != null) throw new CoconaException($"Command '{command.Name}' and option '{overloadCommand.Option}' has more than one option overloads."); resolvedCommand = overloadCommand.Command; continue; } diff --git a/test/Cocona.Test/Command/CommandProvider/GetCommandCollectionFromCommandDataTest.cs b/test/Cocona.Test/Command/CommandProvider/GetCommandCollectionFromCommandDataTest.cs index 0fa2942..8a72728 100644 --- a/test/Cocona.Test/Command/CommandProvider/GetCommandCollectionFromCommandDataTest.cs +++ b/test/Cocona.Test/Command/CommandProvider/GetCommandCollectionFromCommandDataTest.cs @@ -90,7 +90,7 @@ public void TypeCommandData_PrimaryCommand_Duplicate() new TypeCommandData(typeof(CommandTestSingleCommand), new object[] { new CommandNameMetadata("B"), new PrimaryCommandAttribute() }), }); - Assert.Throws(() => provider.GetCommandCollection()).Message.Should().Contain("The commands contains more then one primary command."); + Assert.Throws(() => provider.GetCommandCollection()).Message.Should().Contain("The commands contain more than one primary command."); } [Fact] diff --git a/test/Cocona.Test/Integration/BuildAppCommandsWithBuilderTest.cs b/test/Cocona.Test/Integration/BuildAppCommandsWithBuilderTest.cs index 9483675..7cc38ce 100644 --- a/test/Cocona.Test/Integration/BuildAppCommandsWithBuilderTest.cs +++ b/test/Cocona.Test/Integration/BuildAppCommandsWithBuilderTest.cs @@ -42,7 +42,7 @@ public void Unnamed_SingleCommand_Duplicated() app.AddCommand(() => Console.WriteLine("Hello Konnichiwa!")); app.Run(); }); - }).Message.Should().Contain("The commands contains more then one primary command"); + }).Message.Should().Contain("The commands contain more than one primary command"); } [Fact]