Fix argument order in help

Closes #188
This commit is contained in:
Patrik Svensson
2021-01-01 13:31:54 +01:00
committed by Patrik Svensson
parent 5cf41725a5
commit b81739567b
7 changed files with 120 additions and 55 deletions

View File

@ -0,0 +1,22 @@
using Spectre.Console.Cli;
namespace Spectre.Console.Tests.Data
{
public sealed class ArgumentOrderSettings : CommandSettings
{
[CommandArgument(0, "[QUX]")]
public int Qux { get; set; }
[CommandArgument(3, "<CORGI>")]
public int Corgi { get; set; }
[CommandArgument(1, "<BAR>")]
public int Bar { get; set; }
[CommandArgument(2, "<BAZ>")]
public int Baz { get; set; }
[CommandArgument(0, "<FOO>")]
public int Foo { get; set; }
}
}

View File

@ -0,0 +1,12 @@
USAGE:
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
ARGUMENTS:
<FOO>
<BAR>
<BAZ>
<CORGI>
[QUX]
OPTIONS:
-h, --help Prints help information

View File

@ -2,8 +2,8 @@ USAGE:
myapp <TEETH> [LEGS] [OPTIONS]
ARGUMENTS:
[LEGS] The number of legs
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information

View File

@ -5,8 +5,8 @@ EXAMPLES:
myapp 12 -c 3
ARGUMENTS:
[LEGS] The number of legs
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information

View File

@ -244,6 +244,24 @@ namespace Spectre.Console.Tests.Unit.Cli
// Then
return Verifier.Verify(output);
}
[Fact]
public Task Should_List_Arguments_In_Correct_Order()
{
// Given
var fixture = new CommandAppFixture();
fixture.WithDefaultCommand<GenericCommand<ArgumentOrderSettings>>();
fixture.Configure(configurator =>
{
configurator.SetApplicationName("myapp");
});
// When
var (_, output, _, _) = fixture.Run("--help");
// Then
return Verifier.Verify(output);
}
}
}
}