using Microsoft.Extensions.DependencyInjection; using RackPeek.Domain.Resources.Switches; using RackPeek.Domain.UseCases.Ports; using Spectre.Console; using Spectre.Console.Cli; namespace Shared.Rcl.Commands.Switches.Ports; public class SwitchPortRemoveSettings : SwitchNameSettings { [CommandOption("--index ")] public int Index { get; set; } } public class SwitchPortRemoveCommand(IServiceProvider sp) : AsyncCommand { public override async Task ExecuteAsync(CommandContext ctx, SwitchPortRemoveSettings s, CancellationToken ct) { using IServiceScope scope = sp.CreateScope(); IRemovePortUseCase useCase = scope.ServiceProvider.GetRequiredService>(); await useCase.ExecuteAsync(s.Name, s.Index); AnsiConsole.MarkupLine($"[green]Port {s.Index} removed from switch '{s.Name}'.[/]"); return 0; } }