Prove that remaining args works in strict mode

Closes #496
This commit is contained in:
Patrik Svensson 2021-10-05 15:22:58 +02:00 committed by Phil Scott
parent e0395dfa2b
commit 2a3763cdc7

View File

@ -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()
{