The documentation doesn't include an example of AddArgument.
I'm actually looking how I can collect a bunch of arguments that are after --.
For example: ./my-command --option1 value1 -- any additional arguments.
How can I get a string[] that contains: "any", "additional", "arguments"?
cc @Keboo @jonsequitur
@tmat I believe what you are looking for is the unparsed tokens on the ParseResult. Something like this:
C#
[Fact]
public void Can_retrieve_unparsed_tokens()
{
var rootCommand = new RootCommand("my-command")
{
new Option<string>("--option1"),
};
rootCommand.TreatUnmatchedTokensAsErrors = false;
var result = rootCommand.Parse("my-command --option1 value1 -- any additional arguments");
result.UnparsedTokens.Should().BeEquivalentTo("any", "additional", "arguments");
}
One additional point: TreatUnmatchedTokensAsErrors isn't necessary here. The behavior of -- is always enabled.