| 123456789101112131415161718192021222324 |
- 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 SwitchPortRemoveSettings : SwitchNameSettings {
- [CommandOption("--index <INDEX>")] public int Index { get; set; }
- }
- public class SwitchPortRemoveCommand(IServiceProvider sp)
- : AsyncCommand<SwitchPortRemoveSettings> {
- public override async Task<int> ExecuteAsync(CommandContext ctx, SwitchPortRemoveSettings s, CancellationToken ct) {
- using IServiceScope scope = sp.CreateScope();
- IRemovePortUseCase<Switch> useCase = scope.ServiceProvider.GetRequiredService<IRemovePortUseCase<Switch>>();
- await useCase.ExecuteAsync(s.Name, s.Index);
- AnsiConsole.MarkupLine($"[green]Port {s.Index} removed from switch '{s.Name}'.[/]");
- return 0;
- }
- }
|