mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-02 10:58:17 +08:00

committed by
Patrik Svensson

parent
5cf41725a5
commit
b81739567b
@ -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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
USAGE:
|
||||
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
|
||||
|
||||
ARGUMENTS:
|
||||
<FOO>
|
||||
<BAR>
|
||||
<BAZ>
|
||||
<CORGI>
|
||||
[QUX]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user