Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion src/Aspire.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ public static async Task<int> Main(string[] args)

// Display first run experience if this is the first time the CLI is run on this machine
var configuration = app.Services.GetRequiredService<IConfiguration>();
var noLogo = args.Any(a => a == "--nologo") || configuration.GetBool(CliConfigNames.NoLogo, defaultValue: false);
var hasVersionFlag = args.Any(a => a == "--version");
var noLogo = args.Any(a => a == "--nologo") || configuration.GetBool(CliConfigNames.NoLogo, defaultValue: false) || hasVersionFlag;
Comment thread
JamesNK marked this conversation as resolved.
Outdated
Comment thread
JamesNK marked this conversation as resolved.
Outdated
var showBanner = args.Any(a => a == "--banner");
await DisplayFirstTimeUseNoticeIfNeededAsync(app.Services, noLogo, showBanner, cts.Token);

Expand Down
29 changes: 29 additions & 0 deletions tests/Aspire.Cli.Tests/CliSmokeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,33 @@ public void DebugOutputWritesToStderr()

outputHelper.WriteLine(result.Process.StandardOutput.ReadToEnd());
}

[Fact]
public void VersionFlagSuppressesBanner()
{
using var result = RemoteExecutor.Invoke(async () =>
{
await using var outputWriter = new StringWriter();
var oldOutput = Console.Out;
Console.SetOut(outputWriter);

await Program.Main(["--version"]).DefaultTimeout();

Console.SetOut(oldOutput);
var output = outputWriter.ToString();

// Write to stdout so it can be captured by the test harness
Console.WriteLine($"Output: {output}");

// The output should only contain the version, not the animated banner
// The banner contains "Welcome to the" and ASCII art
Assert.DoesNotContain("Welcome to the", output);
Assert.DoesNotContain("█████", output);

// The output should contain a version number
Assert.Contains(".", output); // Version should have at least one dot
}, options: s_remoteInvokeOptions);

outputHelper.WriteLine(result.Process.StandardOutput.ReadToEnd());
}
Comment thread
JamesNK marked this conversation as resolved.
}
Loading