using Microsoft.Extensions.DependencyInjection; using RackPeek.Domain.Resources.AccessPoints; using Spectre.Console; using Spectre.Console.Cli; namespace Shared.Rcl.Commands.AccessPoints; public class AccessPointGetCommand( IServiceProvider serviceProvider ) : AsyncCommand { public override async Task ExecuteAsync( CommandContext context, CancellationToken cancellationToken) { using IServiceScope scope = serviceProvider.CreateScope(); AccessPointHardwareReportUseCase useCase = scope.ServiceProvider.GetRequiredService(); AccessPointHardwareReport report = await useCase.ExecuteAsync(); if (report.AccessPoints.Count == 0) { AnsiConsole.MarkupLine("[yellow]No access points found.[/]"); return 0; } Table table = new Table() .Border(TableBorder.Rounded) .AddColumn("Name") .AddColumn("Model") .AddColumn("Speed (Gbps)"); foreach (AccessPointHardwareRow ap in report.AccessPoints) table.AddRow( ap.Name, ap.Model, ap.SpeedGb.ToString() ); AnsiConsole.Write(table); return 0; } }