mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-14 16:02:50 +08:00
parent
e0395dfa2b
commit
2a3763cdc7
@ -547,6 +547,45 @@ namespace Spectre.Console.Tests.Unit.Cli
|
||||
result.Context.ShouldHaveRemainingArgument("foo", values: new[] { "bar" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Add_Unknown_Option_To_Remaining_Arguments_In_Strict_Mode()
|
||||
{
|
||||
// Given
|
||||
var app = new CommandAppTester();
|
||||
app.Configure(config =>
|
||||
{
|
||||
config.UseStrictParsing();
|
||||
config.PropagateExceptions();
|
||||
config.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
});
|
||||
|
||||
// When
|
||||
var result = app.Run(new[]
|
||||
{
|
||||
"animal", "4", "dog", "12",
|
||||
"--",
|
||||
"--foo", "bar",
|
||||
"-f", "baz",
|
||||
"qux"
|
||||
});
|
||||
|
||||
// Then
|
||||
result.Context.ShouldNotBeNull();
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(2);
|
||||
result.Context.ShouldHaveRemainingArgument("foo", values: new[] { "bar" });
|
||||
result.Context.ShouldHaveRemainingArgument("f", values: new[] { "baz" });
|
||||
result.Context.Remaining.Raw.Count.ShouldBe(5);
|
||||
result.Context.Remaining.Raw.ShouldBe(new[]
|
||||
{
|
||||
"--foo", "bar",
|
||||
"-f", "baz",
|
||||
"qux",
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Add_Unknown_Boolean_Option_To_Remaining_Arguments_In_Relaxed_Mode()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user