Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 9b77dc5

Browse files
committed
Redirect parser to localized validation messages
1 parent 0353374 commit 9b77dc5

24 files changed

+881
-9
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Linq;
5+
6+
namespace Microsoft.DotNet.Cli.CommandLine
7+
{
8+
internal sealed class CommandLineValidationMessages : IValidationMessages
9+
{
10+
public string CommandAcceptsOnlyOneArgument(string command, int argumentCount) =>
11+
string.Format(LocalizableStrings.CommandAcceptsOnlyOneArgument, command, argumentCount);
12+
13+
public string CommandAcceptsOnlyOneSubcommand(string command, string subcommandsSpecified) =>
14+
string.Format(LocalizableStrings.CommandAcceptsOnlyOneSubcommand, command, subcommandsSpecified);
15+
16+
public string FileDoesNotExist(string filePath) =>
17+
string.Format(LocalizableStrings.FileDoesNotExist, filePath);
18+
19+
public string NoArgumentsAllowed(string option) =>
20+
string.Format(LocalizableStrings.NoArgumentsAllowed, option);
21+
22+
public string OptionAcceptsOnlyOneArgument(string option, int argumentCount) =>
23+
string.Format(LocalizableStrings.OptionAcceptsOnlyOneArgument, option, argumentCount);
24+
25+
public string RequiredArgumentMissingForCommand(string command) =>
26+
string.Format(LocalizableStrings.RequiredArgumentMissingForCommand, command);
27+
28+
public string RequiredArgumentMissingForOption(string option) =>
29+
string.Format(LocalizableStrings.RequiredArgumentMissingForOption, option);
30+
31+
public string RequiredCommandWasNotProvided() =>
32+
string.Format(LocalizableStrings.RequiredCommandWasNotProvided);
33+
34+
public string UnrecognizedArgument(string unrecognizedArg, string[] allowedValues) =>
35+
string.Format(LocalizableStrings.UnrecognizedArgument, unrecognizedArg, $"\n\t{string.Join("\n\t", allowedValues.Select(v => $"'{v}'"))}");
36+
37+
public string UnrecognizedCommandOrArgument(string arg) =>
38+
string.Format(LocalizableStrings.UnrecognizedCommandOrArgument, arg);
39+
40+
public string UnrecognizedOption(string unrecognizedOption, string[] allowedValues) =>
41+
string.Format(LocalizableStrings.UnrecognizedOption, unrecognizedOption, $"\n\t{string.Join("\n\t", allowedValues.Select(v => $"'{v}'"))}");
42+
}
43+
}

src/dotnet/CommandLine/LocalizableStrings.resx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,37 @@
180180
<data name="MSBuildAdditionalArgsHelpText" xml:space="preserve">
181181
<value>Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options.</value>
182182
</data>
183+
<data name="CommandAcceptsOnlyOneArgument" xml:space="preserve">
184+
<value>Command '{0}' only accepts a single argument but {1} were provided.</value>
185+
</data>
186+
<data name="CommandAcceptsOnlyOneSubcommand" xml:space="preserve">
187+
<value>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</value>
188+
</data>
189+
<data name="FileDoesNotExist" xml:space="preserve">
190+
<value>File does not exist: {0}</value>
191+
</data>
192+
<data name="NoArgumentsAllowed" xml:space="preserve">
193+
<value>Arguments not allowed for option: {0}</value>
194+
</data>
195+
<data name="OptionAcceptsOnlyOneArgument" xml:space="preserve">
196+
<value>Option '{0}' only accepts a single argument but {1} were provided.</value>
197+
</data>
198+
<data name="RequiredArgumentMissingForCommand" xml:space="preserve">
199+
<value>Required argument missing for command: {0}</value>
200+
</data>
201+
<data name="RequiredArgumentMissingForOption" xml:space="preserve">
202+
<value>Required argument missing for option: {0}</value>
203+
</data>
204+
<data name="RequiredCommandWasNotProvided" xml:space="preserve">
205+
<value>Required command was not provided.</value>
206+
</data>
207+
<data name="UnrecognizedArgument" xml:space="preserve">
208+
<value>Argument '{0}' not recognized. Must be one of: {1}</value>
209+
</data>
210+
<data name="UnrecognizedCommandOrArgument" xml:space="preserve">
211+
<value>Unrecognized command or argument '{0}'</value>
212+
</data>
213+
<data name="UnrecognizedOption" xml:space="preserve">
214+
<value>Option '{0}' not recognized. Must be one of: {1}</value>
215+
</data>
183216
</root>

src/dotnet/CommandLine/xlf/LocalizableStrings.cs.xlf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@
107107
<target state="translated">Nebyla zadána povinná hodnota parametru {0}.</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unit id="CommandAcceptsOnlyOneArgument">
111+
<source>Command '{0}' only accepts a single argument but {1} were provided.</source>
112+
<target state="new">Command '{0}' only accepts a single argument but {1} were provided.</target>
113+
<note />
114+
</trans-unit>
115+
<trans-unit id="CommandAcceptsOnlyOneSubcommand">
116+
<source>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</source>
117+
<target state="new">Command '{0}' only accepts a single subcommand but multiple were provided: {1}</target>
118+
<note />
119+
</trans-unit>
120+
<trans-unit id="FileDoesNotExist">
121+
<source>File does not exist: {0}</source>
122+
<target state="new">File does not exist: {0}</target>
123+
<note />
124+
</trans-unit>
125+
<trans-unit id="NoArgumentsAllowed">
126+
<source>Arguments not allowed for option: {0}</source>
127+
<target state="new">Arguments not allowed for option: {0}</target>
128+
<note />
129+
</trans-unit>
130+
<trans-unit id="OptionAcceptsOnlyOneArgument">
131+
<source>Option '{0}' only accepts a single argument but {1} were provided.</source>
132+
<target state="new">Option '{0}' only accepts a single argument but {1} were provided.</target>
133+
<note />
134+
</trans-unit>
135+
<trans-unit id="RequiredArgumentMissingForCommand">
136+
<source>Required argument missing for command: {0}</source>
137+
<target state="new">Required argument missing for command: {0}</target>
138+
<note />
139+
</trans-unit>
140+
<trans-unit id="RequiredArgumentMissingForOption">
141+
<source>Required argument missing for option: {0}</source>
142+
<target state="new">Required argument missing for option: {0}</target>
143+
<note />
144+
</trans-unit>
145+
<trans-unit id="RequiredCommandWasNotProvided">
146+
<source>Required command was not provided.</source>
147+
<target state="new">Required command was not provided.</target>
148+
<note />
149+
</trans-unit>
150+
<trans-unit id="UnrecognizedArgument">
151+
<source>Argument '{0}' not recognized. Must be one of: {1}</source>
152+
<target state="new">Argument '{0}' not recognized. Must be one of: {1}</target>
153+
<note />
154+
</trans-unit>
155+
<trans-unit id="UnrecognizedCommandOrArgument">
156+
<source>Unrecognized command or argument '{0}'</source>
157+
<target state="new">Unrecognized command or argument '{0}'</target>
158+
<note />
159+
</trans-unit>
160+
<trans-unit id="UnrecognizedOption">
161+
<source>Option '{0}' not recognized. Must be one of: {1}</source>
162+
<target state="new">Option '{0}' not recognized. Must be one of: {1}</target>
163+
<note />
164+
</trans-unit>
110165
</body>
111166
</file>
112167
</xliff>

src/dotnet/CommandLine/xlf/LocalizableStrings.de.xlf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@
107107
<target state="translated">Der erforderliche Wert für die Option "{0}" wurde nicht angegeben.</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unit id="CommandAcceptsOnlyOneArgument">
111+
<source>Command '{0}' only accepts a single argument but {1} were provided.</source>
112+
<target state="new">Command '{0}' only accepts a single argument but {1} were provided.</target>
113+
<note />
114+
</trans-unit>
115+
<trans-unit id="CommandAcceptsOnlyOneSubcommand">
116+
<source>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</source>
117+
<target state="new">Command '{0}' only accepts a single subcommand but multiple were provided: {1}</target>
118+
<note />
119+
</trans-unit>
120+
<trans-unit id="FileDoesNotExist">
121+
<source>File does not exist: {0}</source>
122+
<target state="new">File does not exist: {0}</target>
123+
<note />
124+
</trans-unit>
125+
<trans-unit id="NoArgumentsAllowed">
126+
<source>Arguments not allowed for option: {0}</source>
127+
<target state="new">Arguments not allowed for option: {0}</target>
128+
<note />
129+
</trans-unit>
130+
<trans-unit id="OptionAcceptsOnlyOneArgument">
131+
<source>Option '{0}' only accepts a single argument but {1} were provided.</source>
132+
<target state="new">Option '{0}' only accepts a single argument but {1} were provided.</target>
133+
<note />
134+
</trans-unit>
135+
<trans-unit id="RequiredArgumentMissingForCommand">
136+
<source>Required argument missing for command: {0}</source>
137+
<target state="new">Required argument missing for command: {0}</target>
138+
<note />
139+
</trans-unit>
140+
<trans-unit id="RequiredArgumentMissingForOption">
141+
<source>Required argument missing for option: {0}</source>
142+
<target state="new">Required argument missing for option: {0}</target>
143+
<note />
144+
</trans-unit>
145+
<trans-unit id="RequiredCommandWasNotProvided">
146+
<source>Required command was not provided.</source>
147+
<target state="new">Required command was not provided.</target>
148+
<note />
149+
</trans-unit>
150+
<trans-unit id="UnrecognizedArgument">
151+
<source>Argument '{0}' not recognized. Must be one of: {1}</source>
152+
<target state="new">Argument '{0}' not recognized. Must be one of: {1}</target>
153+
<note />
154+
</trans-unit>
155+
<trans-unit id="UnrecognizedCommandOrArgument">
156+
<source>Unrecognized command or argument '{0}'</source>
157+
<target state="new">Unrecognized command or argument '{0}'</target>
158+
<note />
159+
</trans-unit>
160+
<trans-unit id="UnrecognizedOption">
161+
<source>Option '{0}' not recognized. Must be one of: {1}</source>
162+
<target state="new">Option '{0}' not recognized. Must be one of: {1}</target>
163+
<note />
164+
</trans-unit>
110165
</body>
111166
</file>
112167
</xliff>

src/dotnet/CommandLine/xlf/LocalizableStrings.es.xlf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@
107107
<target state="translated">No se ha proporcionado el valor requerido para la opción "{0}".</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unit id="CommandAcceptsOnlyOneArgument">
111+
<source>Command '{0}' only accepts a single argument but {1} were provided.</source>
112+
<target state="new">Command '{0}' only accepts a single argument but {1} were provided.</target>
113+
<note />
114+
</trans-unit>
115+
<trans-unit id="CommandAcceptsOnlyOneSubcommand">
116+
<source>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</source>
117+
<target state="new">Command '{0}' only accepts a single subcommand but multiple were provided: {1}</target>
118+
<note />
119+
</trans-unit>
120+
<trans-unit id="FileDoesNotExist">
121+
<source>File does not exist: {0}</source>
122+
<target state="new">File does not exist: {0}</target>
123+
<note />
124+
</trans-unit>
125+
<trans-unit id="NoArgumentsAllowed">
126+
<source>Arguments not allowed for option: {0}</source>
127+
<target state="new">Arguments not allowed for option: {0}</target>
128+
<note />
129+
</trans-unit>
130+
<trans-unit id="OptionAcceptsOnlyOneArgument">
131+
<source>Option '{0}' only accepts a single argument but {1} were provided.</source>
132+
<target state="new">Option '{0}' only accepts a single argument but {1} were provided.</target>
133+
<note />
134+
</trans-unit>
135+
<trans-unit id="RequiredArgumentMissingForCommand">
136+
<source>Required argument missing for command: {0}</source>
137+
<target state="new">Required argument missing for command: {0}</target>
138+
<note />
139+
</trans-unit>
140+
<trans-unit id="RequiredArgumentMissingForOption">
141+
<source>Required argument missing for option: {0}</source>
142+
<target state="new">Required argument missing for option: {0}</target>
143+
<note />
144+
</trans-unit>
145+
<trans-unit id="RequiredCommandWasNotProvided">
146+
<source>Required command was not provided.</source>
147+
<target state="new">Required command was not provided.</target>
148+
<note />
149+
</trans-unit>
150+
<trans-unit id="UnrecognizedArgument">
151+
<source>Argument '{0}' not recognized. Must be one of: {1}</source>
152+
<target state="new">Argument '{0}' not recognized. Must be one of: {1}</target>
153+
<note />
154+
</trans-unit>
155+
<trans-unit id="UnrecognizedCommandOrArgument">
156+
<source>Unrecognized command or argument '{0}'</source>
157+
<target state="new">Unrecognized command or argument '{0}'</target>
158+
<note />
159+
</trans-unit>
160+
<trans-unit id="UnrecognizedOption">
161+
<source>Option '{0}' not recognized. Must be one of: {1}</source>
162+
<target state="new">Option '{0}' not recognized. Must be one of: {1}</target>
163+
<note />
164+
</trans-unit>
110165
</body>
111166
</file>
112167
</xliff>

src/dotnet/CommandLine/xlf/LocalizableStrings.fr.xlf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@
107107
<target state="translated">La valeur nécessaire pour l'option '{0}' n'a pas été fournie.</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unit id="CommandAcceptsOnlyOneArgument">
111+
<source>Command '{0}' only accepts a single argument but {1} were provided.</source>
112+
<target state="new">Command '{0}' only accepts a single argument but {1} were provided.</target>
113+
<note />
114+
</trans-unit>
115+
<trans-unit id="CommandAcceptsOnlyOneSubcommand">
116+
<source>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</source>
117+
<target state="new">Command '{0}' only accepts a single subcommand but multiple were provided: {1}</target>
118+
<note />
119+
</trans-unit>
120+
<trans-unit id="FileDoesNotExist">
121+
<source>File does not exist: {0}</source>
122+
<target state="new">File does not exist: {0}</target>
123+
<note />
124+
</trans-unit>
125+
<trans-unit id="NoArgumentsAllowed">
126+
<source>Arguments not allowed for option: {0}</source>
127+
<target state="new">Arguments not allowed for option: {0}</target>
128+
<note />
129+
</trans-unit>
130+
<trans-unit id="OptionAcceptsOnlyOneArgument">
131+
<source>Option '{0}' only accepts a single argument but {1} were provided.</source>
132+
<target state="new">Option '{0}' only accepts a single argument but {1} were provided.</target>
133+
<note />
134+
</trans-unit>
135+
<trans-unit id="RequiredArgumentMissingForCommand">
136+
<source>Required argument missing for command: {0}</source>
137+
<target state="new">Required argument missing for command: {0}</target>
138+
<note />
139+
</trans-unit>
140+
<trans-unit id="RequiredArgumentMissingForOption">
141+
<source>Required argument missing for option: {0}</source>
142+
<target state="new">Required argument missing for option: {0}</target>
143+
<note />
144+
</trans-unit>
145+
<trans-unit id="RequiredCommandWasNotProvided">
146+
<source>Required command was not provided.</source>
147+
<target state="new">Required command was not provided.</target>
148+
<note />
149+
</trans-unit>
150+
<trans-unit id="UnrecognizedArgument">
151+
<source>Argument '{0}' not recognized. Must be one of: {1}</source>
152+
<target state="new">Argument '{0}' not recognized. Must be one of: {1}</target>
153+
<note />
154+
</trans-unit>
155+
<trans-unit id="UnrecognizedCommandOrArgument">
156+
<source>Unrecognized command or argument '{0}'</source>
157+
<target state="new">Unrecognized command or argument '{0}'</target>
158+
<note />
159+
</trans-unit>
160+
<trans-unit id="UnrecognizedOption">
161+
<source>Option '{0}' not recognized. Must be one of: {1}</source>
162+
<target state="new">Option '{0}' not recognized. Must be one of: {1}</target>
163+
<note />
164+
</trans-unit>
110165
</body>
111166
</file>
112167
</xliff>

src/dotnet/CommandLine/xlf/LocalizableStrings.it.xlf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@
107107
<target state="translated">Il valore obbligatorio per l'opzione '{0}' non è stato specificato.</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unit id="CommandAcceptsOnlyOneArgument">
111+
<source>Command '{0}' only accepts a single argument but {1} were provided.</source>
112+
<target state="new">Command '{0}' only accepts a single argument but {1} were provided.</target>
113+
<note />
114+
</trans-unit>
115+
<trans-unit id="CommandAcceptsOnlyOneSubcommand">
116+
<source>Command '{0}' only accepts a single subcommand but multiple were provided: {1}</source>
117+
<target state="new">Command '{0}' only accepts a single subcommand but multiple were provided: {1}</target>
118+
<note />
119+
</trans-unit>
120+
<trans-unit id="FileDoesNotExist">
121+
<source>File does not exist: {0}</source>
122+
<target state="new">File does not exist: {0}</target>
123+
<note />
124+
</trans-unit>
125+
<trans-unit id="NoArgumentsAllowed">
126+
<source>Arguments not allowed for option: {0}</source>
127+
<target state="new">Arguments not allowed for option: {0}</target>
128+
<note />
129+
</trans-unit>
130+
<trans-unit id="OptionAcceptsOnlyOneArgument">
131+
<source>Option '{0}' only accepts a single argument but {1} were provided.</source>
132+
<target state="new">Option '{0}' only accepts a single argument but {1} were provided.</target>
133+
<note />
134+
</trans-unit>
135+
<trans-unit id="RequiredArgumentMissingForCommand">
136+
<source>Required argument missing for command: {0}</source>
137+
<target state="new">Required argument missing for command: {0}</target>
138+
<note />
139+
</trans-unit>
140+
<trans-unit id="RequiredArgumentMissingForOption">
141+
<source>Required argument missing for option: {0}</source>
142+
<target state="new">Required argument missing for option: {0}</target>
143+
<note />
144+
</trans-unit>
145+
<trans-unit id="RequiredCommandWasNotProvided">
146+
<source>Required command was not provided.</source>
147+
<target state="new">Required command was not provided.</target>
148+
<note />
149+
</trans-unit>
150+
<trans-unit id="UnrecognizedArgument">
151+
<source>Argument '{0}' not recognized. Must be one of: {1}</source>
152+
<target state="new">Argument '{0}' not recognized. Must be one of: {1}</target>
153+
<note />
154+
</trans-unit>
155+
<trans-unit id="UnrecognizedCommandOrArgument">
156+
<source>Unrecognized command or argument '{0}'</source>
157+
<target state="new">Unrecognized command or argument '{0}'</target>
158+
<note />
159+
</trans-unit>
160+
<trans-unit id="UnrecognizedOption">
161+
<source>Option '{0}' not recognized. Must be one of: {1}</source>
162+
<target state="new">Option '{0}' not recognized. Must be one of: {1}</target>
163+
<note />
164+
</trans-unit>
110165
</body>
111166
</file>
112167
</xliff>

0 commit comments

Comments
 (0)