using System.ComponentModel; using Microsoft.Extensions.DependencyInjection; using RackPeek.Domain.Resources.Laptops; using RackPeek.Domain.UseCases.Cpus; using Spectre.Console; using Spectre.Console.Cli; namespace Shared.Rcl.Commands.Laptops.Cpus; public class LaptopCpuRemoveSettings : CommandSettings { [CommandArgument(0, "")] [Description("The name of the Laptop.")] public string LaptopName { get; set; } = default!; [CommandArgument(1, "")] [Description("The index of the Laptop cpu to remove.")] public int Index { get; set; } } public class LaptopCpuRemoveCommand(IServiceProvider provider) : AsyncCommand { public override async Task ExecuteAsync( CommandContext context, LaptopCpuRemoveSettings settings, CancellationToken cancellationToken) { using IServiceScope scope = provider.CreateScope(); IRemoveCpuUseCase useCase = scope.ServiceProvider.GetRequiredService>(); await useCase.ExecuteAsync(settings.LaptopName, settings.Index); AnsiConsole.MarkupLine($"[green]CPU #{settings.Index} removed from Laptop '{settings.LaptopName}'.[/]"); return 0; } }