mycroforge/MycroForge.CLI/Extensions/ServiceCollectionExtensions.cs

58 lines
3.3 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using MycroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Features;
namespace MycroForge.CLI.Extensions;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddServices(this IServiceCollection services)
{
services.AddScoped<ProjectContext>();
services.AddScoped<IFeature, Git>();
services.AddScoped<IFeature, Api>();
services.AddScoped<IFeature, Db>();
return services;
}
public static IServiceCollection AddCommands(this IServiceCollection services)
{
// Register "m4g"
services.AddScoped<Commands.MycroForge>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Init>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Install>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Uninstall>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Hydrate>();
// Register "m4g generate"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Generate>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Generate>, Commands.MycroForge.Generate.Service>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Generate>, Commands.MycroForge.Generate.Venv>();
// Register "m4g api"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Api>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Api>, Commands.MycroForge.Api.Run>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Api>, Commands.MycroForge.Api.Generate>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Api.Generate>, Commands.MycroForge.Api.Generate.Router>();
// Register "m4g orm"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Db>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db>, Commands.MycroForge.Db.Migrate>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db>, Commands.MycroForge.Db.Rollback>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db>, Commands.MycroForge.Db.Generate>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db.Generate>, Commands.MycroForge.Db.Generate.Entity>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db.Generate>, Commands.MycroForge.Db.Generate.Migration>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db>, Commands.MycroForge.Db.Link>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db.Link>, Commands.MycroForge.Db.Link.One>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Db.Link>, Commands.MycroForge.Db.Link.Many>();
// Register "m4g script"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Script>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Script>, Commands.MycroForge.Script.Create>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Script>, Commands.MycroForge.Script.Edit>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Script>, Commands.MycroForge.Script.Run>();
return services;
}
}