Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Aspire.Cli/Commands/RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using System.CommandLine.Help;

#if DEBUG
using System.Globalization;
Expand Down Expand Up @@ -121,13 +122,19 @@ public RootCommand(
Options.Add(WaitForDebuggerOption);
Options.Add(CliWaitForDebuggerOption);

// Handle standalone 'aspire --banner' (no subcommand)
// Handle standalone 'aspire' or 'aspire --banner' (no subcommand)
this.SetAction((context, cancellationToken) =>
{
var bannerRequested = context.GetValue(BannerOption);
// If --banner was passed, we've already shown it in Main, just exit successfully
// Otherwise, show the standard "no command" error
return Task.FromResult(bannerRequested ? 0 : 1);
if (bannerRequested)
{
// If --banner was passed, we've already shown it in Main, just exit successfully
return Task.FromResult(0);
}

// No subcommand provided - show help
new HelpAction().Invoke(context);
return Task.FromResult(0);
Comment thread
davidfowl marked this conversation as resolved.
Outdated
Comment thread
davidfowl marked this conversation as resolved.
Outdated
});

Subcommands.Add(newCommand);
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Cli/Mcp/McpErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class McpErrorMessages
/// </summary>
public const string NoAppHostRunning =
"No Aspire AppHost is currently running. " +
"To use Aspire MCP tools, you must first start an Aspire application by running 'aspire run' in your AppHost project directory. " +
"To use Aspire MCP tools, you must first start an Aspire application by running 'aspire run --detach' in your AppHost project directory. " +
"Once the application is running, the MCP tools will be able to connect to the dashboard and execute commands.";

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public async Task ExecuteResourceCommandTool_ThrowsException_WhenNoAppHostRunnin
() => tool.CallToolAsync(null!, CreateArguments("test-resource", "resource-start"), CancellationToken.None).AsTask()).DefaultTimeout();

Assert.Contains("No Aspire AppHost", exception.Message);
Assert.Contains("--detach", exception.Message);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions tests/Aspire.Cli.Tests/Mcp/ListConsoleLogsToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async Task ListConsoleLogsTool_ThrowsException_WhenNoAppHostRunning()
() => tool.CallToolAsync(null!, arguments, CancellationToken.None).AsTask()).DefaultTimeout();

Assert.Contains("No Aspire AppHost", exception.Message);
Assert.Contains("--detach", exception.Message);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions tests/Aspire.Cli.Tests/Mcp/ListResourcesToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public async Task ListResourcesTool_ThrowsException_WhenNoAppHostRunning()
() => tool.CallToolAsync(null!, null, CancellationToken.None).AsTask()).DefaultTimeout();

Assert.Contains("No Aspire AppHost", exception.Message);
Assert.Contains("--detach", exception.Message);
}

[Fact]
Expand Down
Loading