using System.ComponentModel; using Microsoft.Extensions.DependencyInjection; using RackPeek.Domain.Resources.OtherHardware; using RackPeek.Domain.UseCases.Ports; using Spectre.Console; using Spectre.Console.Cli; namespace Shared.Rcl.Commands.OtherHardware.Ports; public class OtherPortRemoveSettings : OtherNameSettings { [CommandOption("--index ")] [Description("The index of the port to remove.")] public int Index { get; set; } } public class OtherPortRemoveCommand(IServiceProvider sp) : AsyncCommand { protected override async Task ExecuteAsync(CommandContext ctx, OtherPortRemoveSettings 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 other hardware '{s.Name}'.[/]"); return 0; } }