Open
Description
I have a root command with subcommands (verbs).
The subcommands accept 0 .. n strings as arguments -- they're command arguments, not option arguments.
var root = new RootCommand()
{
new Command("foo")
{
new Argument<string[]>("filter", Array.Empty<string>)
}
};
I can create a handler for that which expects string[]
as a parameter.
But what I want is:
- The handler should take a more complex user-defined type (named
Filter
), as its parameter - The command-line parser should use the
string[]
to instantiate that type
I thought that I could do that, using Model Binding -- More complex types -- but I tried and failed (with a run-time exception like "Cannot convert string[] to Filter").
- Is this scenario supported, or is that only (as it says) for "binding
Option
arguments" and not for bindingArguments
? - Or if it is supported, is there an example or maybe a unit test of its being done?
As a work-around I can convert/instantiate it myself within the command-handler; but I wanted it done automatically because there are many commands which all expect the same kind of arguments type.