-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetTransportCommand.cs
More file actions
26 lines (23 loc) · 1.03 KB
/
SetTransportCommand.cs
File metadata and controls
26 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using BuslyCLI.Config;
using Spectre.Console;
using Spectre.Console.Cli;
namespace BuslyCLI.Commands.Transport;
public class SetTransportCommand(IAnsiConsole console, INServiceBusConfiguration nservicebusConfiguration)
: AsyncCommand<SetTransportSettings>
{
protected override async Task<int> ExecuteAsync(CommandContext context, SetTransportSettings settings, CancellationToken cancellationToken)
{
var nsbConfiguration = await nservicebusConfiguration.GetValidatedConfigurationAsync(settings.Config.Path);
var targetTransport = settings.TransportName.ToLower();
if (nsbConfiguration.Transports.Select(x => x.Name.ToLower()).Contains(targetTransport))
{
await nservicebusConfiguration.UpdateCurrentTransportAsync(settings.Config.Path, targetTransport);
console.WriteLine($"Switched to transport \"{targetTransport}\".");
}
else
{
console.WriteLine($"No transport exists with the name {targetTransport}.");
}
return 0;
}
}