|
1 | 1 | using servicebus_cli.Services; |
2 | | -using Spectre.Console; |
3 | 2 |
|
4 | 3 | namespace servicebus_cli.Subjects.Queue.Actions; |
5 | 4 |
|
@@ -51,41 +50,38 @@ public async Task List(List<string> args) |
51 | 50 | break; |
52 | 51 | } |
53 | 52 |
|
54 | | - //TODO: Wrap this inside ConsoleService |
| 53 | + var queueInfoWorkload = async () => |
| 54 | + { |
| 55 | + return await _serviceBusService.GetInformationAboutAllQueues(fullyQualifiedNamespace, filter).ConfigureAwait(false); |
| 56 | + }; |
55 | 57 |
|
56 | | - var table = await AnsiConsole.Status() |
57 | | - .StartAsync($"Listing queues on {fullyQualifiedNamespace}...", async ctx => |
58 | | - { |
59 | | - ctx.Spinner(Spinner.Known.Dots); |
60 | | - ctx.SpinnerStyle(Style.Parse("yellow")); |
61 | | - |
62 | | - var queuesWithInformation = await _serviceBusService.GetInformationAboutAllQueues(fullyQualifiedNamespace, filter).ConfigureAwait(false); |
63 | | - |
64 | | - ctx.Status("Building table..."); |
65 | | - |
66 | | - var resultTable = new Table(); |
67 | | - resultTable.AddColumn("📮 [bold]Queue Name[/]"); |
68 | | - resultTable.AddColumn("[green]Active[/]"); |
69 | | - resultTable.AddColumn("[red]Dead Letter[/]"); |
70 | | - resultTable.AddColumn("[blue]Scheduled[/]"); |
| 58 | + var queuesWithInformation = await _consoleService.ProcessWorkloadWithSpinner( |
| 59 | + $"Listing queues on {fullyQualifiedNamespace}...", |
| 60 | + queueInfoWorkload); |
71 | 61 |
|
72 | | - foreach (var queueInfo in queuesWithInformation) |
73 | | - { |
74 | | - var activeMessageCount = queueInfo.QueueRuntimeProperties.ActiveMessageCount; |
75 | | - var deadLetterMessageCount = queueInfo.QueueRuntimeProperties.DeadLetterMessageCount; |
76 | | - var scheduledMessageCount = queueInfo.QueueRuntimeProperties.ScheduledMessageCount; |
| 62 | + var headers = new List<string> { |
| 63 | + "📮 [bold]Queue Name[/]", |
| 64 | + "[green]Active[/]", |
| 65 | + "[red]Dead Letter[/]", |
| 66 | + "[blue]Scheduled[/]" |
| 67 | + }; |
77 | 68 |
|
78 | | - resultTable.AddRow( |
79 | | - queueInfo.QueueProperties.Name, |
80 | | - $"[green]{activeMessageCount}[/]", |
81 | | - $"[red]{deadLetterMessageCount}[/]", |
82 | | - $"[blue]{scheduledMessageCount}[/]" |
83 | | - ); |
84 | | - } |
85 | | - |
86 | | - return resultTable; |
| 69 | + var rows = new List<List<string>>(); |
| 70 | + |
| 71 | + foreach (var queueInfo in queuesWithInformation) |
| 72 | + { |
| 73 | + var activeMessageCount = queueInfo.QueueRuntimeProperties.ActiveMessageCount; |
| 74 | + var deadLetterMessageCount = queueInfo.QueueRuntimeProperties.DeadLetterMessageCount; |
| 75 | + var scheduledMessageCount = queueInfo.QueueRuntimeProperties.ScheduledMessageCount; |
| 76 | + |
| 77 | + rows.Add(new List<string> { |
| 78 | + queueInfo.QueueProperties.Name, |
| 79 | + $"[green]{activeMessageCount}[/]", |
| 80 | + $"[red]{deadLetterMessageCount}[/]", |
| 81 | + $"[blue]{scheduledMessageCount}[/]" |
87 | 82 | }); |
| 83 | + } |
88 | 84 |
|
89 | | - AnsiConsole.Write(table); |
| 85 | + _consoleService.WriteTable(headers, rows); |
90 | 86 | } |
91 | 87 | } |
0 commit comments