Skip to content

Commit 193fe4d

Browse files
author
Chet Husk
committed
introduce resources for error strings, update comments
1 parent 1742e91 commit 193fe4d

16 files changed

+131
-44
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/Verbosity.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,20 @@ public enum Verbosity
1212
detailed,
1313
diagnostic
1414
}
15+
16+
public static class VerbosityData
17+
{
18+
public static string[] VerbosityNames =
19+
[
20+
"quiet",
21+
"q",
22+
"minimal",
23+
"m",
24+
"normal",
25+
"n",
26+
"detailed",
27+
"d",
28+
"diagnostic",
29+
"diag"
30+
];
31+
}

src/Cli/dotnet/CliStrings.resx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,12 @@
302302
{1}.</value>
303303
</data>
304304
<data name="VerbosityOptionDescription" xml:space="preserve">
305-
<value>Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].</value>
305+
<value>Set the MSBuild verbosity level. Allowed values are: {0}.</value>
306+
<comment>{0} is a comma-separated list of allowed string values</comment>
307+
</data>
308+
<data name="VerbosityParserInvalidToken" xml:space="preserve">
309+
<value>'{0}' is not a valid value for --verbosity. Allowed values are: {1}.</value>
310+
<comment>{0} is the invalid token, {1} is a comma-separated list of allowed string values</comment>
306311
</data>
307312
<data name="CmdVersionSuffixDescription" xml:space="preserve">
308313
<value>Set the value of the $(VersionSuffix) property to use when building the project.</value>

src/Cli/dotnet/CommonOptions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static string[] SplitMSBuildValues(string? defaultValue, ArgumentResult a
143143
public static Option<Verbosity> VerbosityOption(Verbosity defaultVerbosity) =>
144144
new Option<Verbosity>("--verbosity", "-v")
145145
{
146-
Description = CliStrings.VerbosityOptionDescription,
146+
Description = string.Format(CliStrings.VerbosityOptionDescription, string.Join(", ", VerbosityData.VerbosityNames)),
147147
HelpName = CliStrings.LevelArgumentName,
148148
DefaultValueFactory = _ => defaultVerbosity,
149149
CustomParser = static r => ParseVerbosityEnum(r)!.Value
@@ -154,7 +154,7 @@ public static Option<Verbosity> VerbosityOption(Verbosity defaultVerbosity) =>
154154
public static Option<Verbosity?> VerbosityOption() =>
155155
new Option<Verbosity?>("--verbosity", "-v", "--v", "-verbosity", "/v", "/verbosity")
156156
{
157-
Description = CliStrings.VerbosityOptionDescription,
157+
Description = string.Format(CliStrings.VerbosityOptionDescription, string.Join(", ", VerbosityData.VerbosityNames)),
158158
HelpName = CliStrings.LevelArgumentName,
159159
CustomParser = ParseVerbosityEnum
160160
}
@@ -173,7 +173,7 @@ public static Option<Verbosity> VerbosityOption(Verbosity defaultVerbosity) =>
173173
{
174174
[var single] => single.Value,
175175
[.., var last] => last.Value,
176-
_ => throw new InvalidOperationException("Unreachable")
176+
_ => throw new System.Diagnostics.UnreachableException()
177177
};
178178

179179
// happy path: someone used the fully enum case name
@@ -198,7 +198,7 @@ public static Option<Verbosity> VerbosityOption(Verbosity defaultVerbosity) =>
198198
}
199199
else // we couldn't parse it, so report an error
200200
{
201-
result.AddError($"'{tokenToParse}' is not a valid value for --verbosity. Allowed values are: quiet (q), minimal (m), normal (n), detailed (d), diagnostic (diag).");
201+
result.AddError(string.Format(CliStrings.VerbosityParserInvalidToken, tokenToParse, string.Join(", ", VerbosityData.VerbosityNames)));
202202
return default;
203203
}
204204
}

src/Cli/dotnet/xlf/CliStrings.cs.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.de.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.es.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.fr.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.it.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.ja.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.ko.xlf

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)