Add localization support to help provider (#1349)

Closes #1349
This commit is contained in:
Frank Ray
2023-11-10 23:22:52 +00:00
committed by GitHub
parent 023c77ff09
commit 250b1f4c9c
17 changed files with 1057 additions and 36 deletions

View File

@ -0,0 +1,25 @@
BESCHREIBUNG:
The lion command.
VERWENDUNG:
myapp <TEETH> [LEGS] [OPTIONEN] [KOMMANDO]
BEISPIELE:
myapp 20 --alive
ARGUMENTE:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONEN:
STANDARDWERT
-h, --help Zeigt Hilfe an
-v, --version Zeigt Versionsinformationen an
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> 10 The agility between 0 and 100
-c <CHILDREN> The number of children the lion has
-d <DAY> Monday, Thursday The days the lion goes hunting
KOMMANDOS:
giraffe <LENGTH> The giraffe command

View File

@ -4,6 +4,9 @@ The lion command.
USAGE:
myapp <TEETH> [LEGS] [OPTIONS] [COMMAND]
EXAMPLES:
myapp 20 --alive
ARGUMENTS:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs

View File

@ -0,0 +1,25 @@
DESCRIPTION:
The lion command.
UTILISATION:
myapp <TEETH> [LEGS] [OPTIONS] [COMMANDE]
EXEMPLES:
myapp 20 --alive
ARGUMENTS:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONS:
DÉFAUT
-h, --help Affiche l'aide
-v, --version Affiche la version
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> 10 The agility between 0 and 100
-c <CHILDREN> The number of children the lion has
-d <DAY> Monday, Thursday The days the lion goes hunting
COMMANDES:
giraffe <LENGTH> The giraffe command

View File

@ -0,0 +1,25 @@
BESKRIVNING:
The lion command.
ANVÄNDING:
myapp <TEETH> [LEGS] [VAL] [KOMMANDO]
EXEMPEL:
myapp 20 --alive
ARGUMENT:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
VAL:
STANDARD
-h, --help Skriver ut hjälpinformation
-v, --version Skriver ut versionsnummer
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> 10 The agility between 0 and 100
-c <CHILDREN> The number of children the lion has
-d <DAY> Monday, Thursday The days the lion goes hunting
KOMMANDON:
giraffe <LENGTH> The giraffe command

View File

@ -29,15 +29,4 @@
<ProjectReference Include="..\..\src\Spectre.Console\Spectre.Console.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Expectations\Help\Default_Without_Args_Additional.Output.verified.txt">
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<DependentUpon>%(ParentFile).cs</DependentUpon>
</None>
<None Update="Expectations\Help\Default_Greeter.Output.verified.txt">
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<DependentUpon>%(ParentFile).cs</DependentUpon>
</None>
</ItemGroup>
</Project>

View File

@ -230,15 +230,27 @@ public sealed partial class CommandAppTests
return Verifier.Verify(result.Output);
}
[Fact]
[Theory]
[InlineData(null, "EN")]
[InlineData("", "EN")]
[InlineData("en", "EN")]
[InlineData("en-EN", "EN")]
[InlineData("fr", "FR")]
[InlineData("fr-FR", "FR")]
[InlineData("sv", "SV")]
[InlineData("sv-SE", "SV")]
[InlineData("de", "DE")]
[InlineData("de-DE", "DE")]
[Expectation("Default_Without_Args_Additional")]
public Task Should_Output_Default_Command_And_Additional_Commands_When_Default_Command_Has_Required_Parameters_And_Is_Called_Without_Args()
public Task Should_Output_Default_Command_And_Additional_Commands_When_Default_Command_Has_Required_Parameters_And_Is_Called_Without_Args_Localised(string culture, string expectationPrefix)
{
// Given
var fixture = new CommandAppTester();
fixture.SetDefaultCommand<LionCommand>();
fixture.Configure(configurator =>
{
configurator.AddExample("20", "--alive");
configurator.SetApplicationCulture(string.IsNullOrEmpty(culture) ? null : new CultureInfo(culture));
configurator.SetApplicationName("myapp");
configurator.AddCommand<GiraffeCommand>("giraffe");
});
@ -247,7 +259,9 @@ public sealed partial class CommandAppTests
var result = fixture.Run();
// Then
return Verifier.Verify(result.Output);
var settings = new VerifySettings();
settings.DisableRequireUniquePrefix();
return Verifier.Verify(result.Output, settings).UseTextForParameters(expectationPrefix);
}
[Fact]