| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using Microsoft.Extensions.DependencyInjection;
- using RackPeek.Domain.Resources.OtherHardware;
- using Spectre.Console;
- using Spectre.Console.Cli;
- namespace Shared.Rcl.Commands.OtherHardware;
- public class OtherReportCommand(
- IServiceProvider serviceProvider
- ) : AsyncCommand {
- protected override async Task<int> ExecuteAsync(CommandContext context, CancellationToken cancellationToken) {
- using IServiceScope scope = serviceProvider.CreateScope();
- OtherHardwareReportUseCase useCase = scope.ServiceProvider.GetRequiredService<OtherHardwareReportUseCase>();
- OtherHardwareReport report = await useCase.ExecuteAsync();
- if (report.Others.Count == 0) {
- AnsiConsole.MarkupLine("[yellow]No other hardware found.[/]");
- return 0;
- }
- Table table = new Table()
- .Border(TableBorder.Rounded)
- .AddColumn("Name")
- .AddColumn("Model")
- .AddColumn("Description");
- foreach (OtherHardwareRow other in report.Others)
- table.AddRow(
- other.Name,
- other.Model,
- other.Description
- );
- AnsiConsole.Write(table);
- return 0;
- }
- }
|