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 SwitchPortUpdateSettings : SwitchNameSettings { [CommandOption("--index ")] public int Index { get; set; } [CommandOption("--type")] public string? Type { get; set; } [CommandOption("--speed")] public double? Speed { get; set; } [CommandOption("--count")] public int? Count { get; set; } } public class SwitchPortUpdateCommand(IServiceProvider sp) : AsyncCommand { public override async Task ExecuteAsync(CommandContext ctx, SwitchPortUpdateSettings s, CancellationToken ct) { using IServiceScope scope = sp.CreateScope(); IUpdatePortUseCase useCase = scope.ServiceProvider.GetRequiredService>(); await useCase.ExecuteAsync(s.Name, s.Index, s.Type, s.Speed, s.Count); AnsiConsole.MarkupLine($"[green]Port {s.Index} updated on switch '{s.Name}'.[/]"); return 0; } }