Skip to content

Commit 9b1cf6c

Browse files
committed
Tweak presentation of no resources.
1 parent 7b5a5df commit 9b1cf6c

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

src/Aspire.Cli/Commands/RunCommand.cs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,41 +165,51 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
165165
_interactionService.DisplayDashboardUrls(dashboardUrls);
166166

167167
var table = new Table().Border(TableBorder.Rounded);
168+
169+
table.AddColumn("Resource");
170+
table.AddColumn("Type");
171+
table.AddColumn("State");
172+
table.AddColumn("Health");
173+
table.AddColumn("Endpoint(s)");
174+
175+
// We add a default row here to say that
176+
// there are no resources in the app host.
177+
// This will be replaced once the first
178+
// resource is streamed back from the
179+
// app host which should be almost immediate
180+
// if no resources are present.
181+
table.Rows.Add([
182+
new Markup("--"),
183+
new Markup("--"),
184+
new Markup("--"),
185+
new Markup("--"),
186+
new Markup("--"),
187+
]);
188+
168189
var message = new Markup("Press [bold]Ctrl+C[/] to stop the app host and exit.");
169-
var noResourcesMessage = new Markup("No resources are present.");
170190

171-
// Start with noResourcesMessage as the default
172191
var renderables = new List<IRenderable> {
173-
noResourcesMessage,
192+
table,
174193
message
175194
};
176195
var rows = new Rows(renderables);
177196

178197
await _ansiConsole.Live(rows).StartAsync(async context =>
179198
{
180-
var knownResources = new SortedDictionary<string, RpcResourceState>();
181-
var hasResources = false;
199+
// If we are running an apphost that has no
200+
// resources in it then we want to display
201+
// the message that there are no resources.
202+
// That is why we immediately do a refresh.
203+
context.Refresh();
182204

183-
table.AddColumn("Resource");
184-
table.AddColumn("Type");
185-
table.AddColumn("State");
186-
table.AddColumn("Health");
187-
table.AddColumn("Endpoint(s)");
205+
var knownResources = new SortedDictionary<string, RpcResourceState>();
188206

189207
var resourceStates = backchannel.GetResourceStatesAsync(cancellationToken);
190208

191209
try
192210
{
193211
await foreach (var resourceState in resourceStates)
194212
{
195-
if (!hasResources)
196-
{
197-
// First resource found, switch from message to table
198-
hasResources = true;
199-
renderables[0] = table;
200-
context.Refresh();
201-
}
202-
203213
knownResources[resourceState.Resource] = resourceState;
204214

205215
table.Rows.Clear();

0 commit comments

Comments
 (0)