Support IoC container(s) for initializing verb instances.
Closed this issue · 1 comments
nemec commented
Instead of requiring a default constructor, add the ability to initialize verbs from IoC containers and other factories.
nemec commented
This is now supported via an IVerbFactory
parameter to the parser.
var opt = new OptionsWithGitVerbs();
var factory = new SimpleVerbfactory
{
{ () => new GitAdd() },
{ typeof(GitCommit), () => new GitCommit("My default message") }
};
var parser = new CliParser<OptionsWithGitVerbs>(
opt, ParserOptions.None, new AutomaticHelpGenerator<OptionsWithGitVerbs>(), factory);
parser.Parse("add myfile.txt otherfile.txt".Split());