| 123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.ComponentModel;
- using Microsoft.Extensions.DependencyInjection;
- using RackPeek.Domain.Resources.AccessPoints;
- using Shared.Rcl.Commands.Servers;
- using Spectre.Console;
- using Spectre.Console.Cli;
- namespace Shared.Rcl.Commands.AccessPoints;
- public class AccessPointSetSettings : ServerNameSettings {
- [CommandOption("--model")]
- [Description("The access point model name.")]
- public string? Model { get; set; }
- [CommandOption("--speed")]
- [Description("The speed of the access point in Gb.")]
- public double? Speed { get; set; }
- }
- public class AccessPointSetCommand(
- IServiceProvider serviceProvider
- ) : AsyncCommand<AccessPointSetSettings> {
- public override async Task<int> ExecuteAsync(
- CommandContext context,
- AccessPointSetSettings settings,
- CancellationToken cancellationToken) {
- using IServiceScope scope = serviceProvider.CreateScope();
- UpdateAccessPointUseCase useCase = scope.ServiceProvider.GetRequiredService<UpdateAccessPointUseCase>();
- await useCase.ExecuteAsync(
- settings.Name,
- settings.Model,
- settings.Speed
- );
- AnsiConsole.MarkupLine($"[green]Access Point '{settings.Name}' updated.[/]");
- return 0;
- }
- }
|