OtherGetByNameCommand.cs 886 B

123456789101112131415161718192021222324
  1. using Microsoft.Extensions.DependencyInjection;
  2. using RackPeek.Domain.Resources.OtherHardware;
  3. using Spectre.Console;
  4. using Spectre.Console.Cli;
  5. namespace Shared.Rcl.Commands.OtherHardware;
  6. public class OtherGetByNameCommand(IServiceProvider provider)
  7. : AsyncCommand<OtherNameSettings> {
  8. protected override async Task<int> ExecuteAsync(
  9. CommandContext context,
  10. OtherNameSettings settings,
  11. CancellationToken cancellationToken) {
  12. using IServiceScope scope = provider.CreateScope();
  13. DescribeOtherUseCase useCase = scope.ServiceProvider.GetRequiredService<DescribeOtherUseCase>();
  14. OtherDescription other = await useCase.ExecuteAsync(settings.Name);
  15. AnsiConsole.MarkupLine(
  16. $"[green]{other.Name}[/] Model: {other.Model ?? "Unknown"}, Description: {other.Description ?? "Unknown"}");
  17. return 0;
  18. }
  19. }