private (CommandContext, IArgumentParser) GetContextAndArgumentParser(Action <MariCommandsOptions> options = null) { var services = new ServiceCollection(); services.AddOptions <MariCommandsOptions>(); if (options.HasContent()) { services.Configure <MariCommandsOptions>(options); } services.AddTransient <ITypeParserProvider, TypeParserProvider>(); services.AddAllDefaultTypeParsers(true); services.AddTransient <IArgumentParser, ArgumentParser>(); var provider = services.BuildServiceProvider(true); var context = new CommandContext(); context.ServiceScopeFactory = provider.GetRequiredService <IServiceScopeFactory>(); return(context, context.CommandServices.GetRequiredService <IArgumentParser>()); }