58 lines
3.3 KiB
C#
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, Orm>();
|
|
|
|
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.Orm>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm>, Commands.MycroForge.Orm.Migrate>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm>, Commands.MycroForge.Orm.Rollback>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm>, Commands.MycroForge.Orm.Generate>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm.Generate>, Commands.MycroForge.Orm.Generate.Entity>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm.Generate>, Commands.MycroForge.Orm.Generate.Migration>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm>, Commands.MycroForge.Orm.Link>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm.Link>, Commands.MycroForge.Orm.Link.One>();
|
|
services.AddScoped<ISubCommandOf<Commands.MycroForge.Orm.Link>, Commands.MycroForge.Orm.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;
|
|
}
|
|
} |