mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add token representation to remaining arguments
Before, when adding parsed information to the IRemainingArguments.Parsed, we used the name of the parsed option ('foo') instead of it's representation ('--foo'). This commit fixes that.
This commit is contained in:

committed by
Patrik Svensson

parent
95bff47b85
commit
71f762f646
@ -89,7 +89,7 @@ public sealed partial class CommandAppTests
|
||||
//cat.Name.ShouldBe("Kitty"); //<-- Should normally be correct, but instead name will be added to the remaining arguments (see below).
|
||||
});
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("name", values: new[] { "Kitty", });
|
||||
result.Context.ShouldHaveRemainingArgument("--name", values: new[] { "Kitty", });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -56,7 +56,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument(unknownFlag.TrimStart('-'), values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument(unknownFlag, values: new[] { (string)null });
|
||||
result.Context.Remaining.Raw.Count.ShouldBe(0);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("r", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("-r", values: new[] { (string)null });
|
||||
result.Context.Remaining.Raw.Count.ShouldBe(0);
|
||||
}
|
||||
|
||||
@ -189,10 +189,10 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(4);
|
||||
result.Context.ShouldHaveRemainingArgument("foo", values: new[] { "bar", "baz" });
|
||||
result.Context.ShouldHaveRemainingArgument("b", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("a", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("r", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("--foo", values: new[] { "bar", "baz" });
|
||||
result.Context.ShouldHaveRemainingArgument("-b", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("-a", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("-r", values: new[] { (string)null });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -280,7 +280,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("good-boy", values: new[] { "Please be good Rufus!" });
|
||||
result.Context.ShouldHaveRemainingArgument("--good-boy", values: new[] { "Please be good Rufus!" });
|
||||
|
||||
result.Context.Remaining.Raw.Count.ShouldBe(0); // nb. there are no "raw" remaining arguments on the command line
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Output.ShouldBe(string.Empty);
|
||||
result.Context.ShouldHaveRemainingArgument("version", new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("--version", new[] { (string)null });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -70,7 +70,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
result.Output.ShouldBe(string.Empty);
|
||||
result.Context.ShouldHaveRemainingArgument("version", new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("--version", new[] { (string)null });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -215,7 +215,7 @@ public sealed partial class CommandAppTests
|
||||
dog.Name.ShouldBe("\" -Rufus --' ");
|
||||
});
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("order-by", values: new[] { "\"-size\"", " ", string.Empty });
|
||||
result.Context.ShouldHaveRemainingArgument("--order-by", values: new[] { "\"-size\"", " ", string.Empty });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -844,7 +844,7 @@ public sealed partial class CommandAppTests
|
||||
// Then
|
||||
result.Context.ShouldNotBeNull();
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("foo", values: new[] { "bar" });
|
||||
result.Context.ShouldHaveRemainingArgument("--foo", values: new[] { "bar" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -875,8 +875,8 @@ public sealed partial class CommandAppTests
|
||||
// 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.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[]
|
||||
{
|
||||
@ -909,7 +909,7 @@ public sealed partial class CommandAppTests
|
||||
// Then
|
||||
result.Context.ShouldNotBeNull();
|
||||
result.Context.Remaining.Parsed.Count.ShouldBe(1);
|
||||
result.Context.ShouldHaveRemainingArgument("foo", values: new[] { (string)null });
|
||||
result.Context.ShouldHaveRemainingArgument("--foo", values: new[] { (string)null });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Reference in New Issue
Block a user