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