diff --git a/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs b/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs index 9f720012..a1040494 100644 --- a/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs +++ b/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs @@ -5,14 +5,20 @@ namespace BuslyCLI.Commands.ServiceControl.Endpoint; -public class ListEndpointsCommand(IAnsiConsole console, INServiceBusConfiguration nservicebusConfiguration, ServiceControlClient serviceControlClient) +public class ListEndpointsCommand( + IAnsiConsole console, + INServiceBusConfiguration nservicebusConfiguration, + ServiceControlClient serviceControlClient) : AsyncCommand { - protected override async Task ExecuteAsync(CommandContext context, ListEndpointsSettings settings, CancellationToken cancellationToken) + protected override async Task ExecuteAsync(CommandContext context, ListEndpointsSettings settings, + CancellationToken cancellationToken) { var config = await nservicebusConfiguration.GetServiceControlValidatedConfigurationAsync(settings.Config.Path); - var endpoints = await serviceControlClient.GetEndpointsAsync(config.CurrentServiceControlInstanceConfig.Url, cancellationToken); + var endpoints = + await serviceControlClient.GetEndpointsAsync(config.CurrentServiceControlInstanceConfig.Url, + cancellationToken); var table = new Table(); table.AddColumn("Id"); @@ -29,8 +35,13 @@ protected override async Task ExecuteAsync(CommandContext context, ListEndp endpoint.Name, endpoint.HostDisplayName, endpoint.IsSendingHeartbeats ? "Yes" : "No", - endpoint.HeartbeatInformation.ReportedStatus == "dead" ? "[red]Dead[/]" : "[green]Alive[/]", - endpoint.HeartbeatInformation.LastReportAt.ToString("u")); + endpoint.HeartbeatInformation switch + { + null => "No data available", + { ReportedStatus: "dead" } => "[red]Dead[/]", + _ => "[green]Alive[/]" + }, + endpoint.HeartbeatInformation?.LastReportAt.ToString("u") ?? "-"); } console.Write(table);