using System.ComponentModel; using Microsoft.Extensions.DependencyInjection; using RackPeek.Domain.Resources.Desktops; using RackPeek.Domain.UseCases.Drives; using Spectre.Console; using Spectre.Console.Cli; namespace Shared.Rcl.Commands.Desktops.Drive; public class DesktopDriveRemoveSettings : CommandSettings { [CommandArgument(0, "")] [Description("The name of the desktop.")] public string DesktopName { get; set; } = default!; [CommandArgument(1, "")] [Description("The index of the drive to remove.")] public int Index { get; set; } } public class DesktopDriveRemoveCommand(IServiceProvider provider) : AsyncCommand { public override async Task ExecuteAsync( CommandContext context, DesktopDriveRemoveSettings settings, CancellationToken cancellationToken) { using IServiceScope scope = provider.CreateScope(); IRemoveDriveUseCase useCase = scope.ServiceProvider.GetRequiredService>(); await useCase.ExecuteAsync(settings.DesktopName, settings.Index); AnsiConsole.MarkupLine($"[green]Drive #{settings.Index} removed from desktop '{settings.DesktopName}'.[/]"); return 0; } }