Skip to content

Commit a4c4d9e

Browse files
JamesNKCopilot
andauthored
CLI: Make update notifications opt-in and suppress when --format json (#17350)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 2777ae7 commit a4c4d9e

33 files changed

Lines changed: 54 additions & 55 deletions

src/Aspire.Cli/Commands/AddCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ internal sealed class AddCommand : BaseCommand
2121
{
2222
internal override HelpGroup HelpGroup => HelpGroup.AppCommands;
2323

24+
protected override bool UpdateNotificationsEnabled => true;
25+
2426
private readonly IProjectLocator _projectLocator;
2527
private readonly IntegrationPackageSearchService _integrationPackageSearchService;
2628
private readonly IAddCommandPrompter _prompter;

src/Aspire.Cli/Commands/AgentInitCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public AgentInitCommand(
8585
ConsoleInteractionService.NoneChoice)
8686
};
8787

88-
protected override bool UpdateNotificationsEnabled => false;
89-
9088
/// <summary>
9189
/// Public entry point for executing the init command.
9290
/// This allows McpInitCommand to delegate to this implementation.

src/Aspire.Cli/Commands/AgentMcpCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public AgentMcpCommand(
8585
Options.Add(s_apiKeyOption);
8686
}
8787

88-
protected override bool UpdateNotificationsEnabled => false;
89-
9088
/// <summary>
9189
/// Public entry point for executing the MCP server command.
9290
/// This allows McpStartCommand to delegate to this implementation.

src/Aspire.Cli/Commands/ApiGetCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public ApiGetCommand(
5454
Options.Add(s_formatOption);
5555
}
5656

57-
protected override bool UpdateNotificationsEnabled => false;
58-
5957
protected override async Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
6058
{
6159
using var activity = Telemetry.StartDiagnosticActivity(Name);

src/Aspire.Cli/Commands/ApiListCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public ApiListCommand(
5555
Options.Add(s_formatOption);
5656
}
5757

58-
protected override bool UpdateNotificationsEnabled => false;
59-
6058
protected override async Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
6159
{
6260
using var activity = Telemetry.StartDiagnosticActivity(Name);

src/Aspire.Cli/Commands/ApiSearchCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public ApiSearchCommand(
6767
Options.Add(s_limitOption);
6868
}
6969

70-
protected override bool UpdateNotificationsEnabled => false;
71-
7270
protected override async Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
7371
{
7472
using var activity = Telemetry.StartDiagnosticActivity(Name);

src/Aspire.Cli/Commands/BaseCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal abstract class BaseCommand : Command
1717
{
1818
private static readonly int[] s_suppressErrorLogsMessageExitCodes = [CliExitCodes.Cancelled, CliExitCodes.MissingRequiredArgument];
1919

20-
protected virtual bool UpdateNotificationsEnabled { get; } = true;
20+
protected virtual bool UpdateNotificationsEnabled { get; }
2121

2222
/// <summary>
2323
/// Gets the help group for this command.
@@ -114,7 +114,7 @@ protected BaseCommand(string name, string description, IFeatures features, ICliU
114114
}
115115
}
116116

117-
if (UpdateNotificationsEnabled && features.IsFeatureEnabled(KnownFeatures.UpdateNotificationsEnabled, true))
117+
if (UpdateNotificationsEnabled && !IsJsonFormatRequested(parseResult) && features.IsFeatureEnabled(KnownFeatures.UpdateNotificationsEnabled, true))
118118
{
119119
try
120120
{

src/Aspire.Cli/Commands/CacheCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public ClearCommand(IInteractionService interactionService, IFeatures features,
3030
{
3131
}
3232

33-
protected override bool UpdateNotificationsEnabled => false;
34-
3533
protected override Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
3634
{
3735
try

src/Aspire.Cli/Commands/CertificatesCleanCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public CertificatesCleanCommand(ICertificateToolRunner certificateToolRunner, II
2525
_certificateToolRunner = certificateToolRunner;
2626
}
2727

28-
protected override bool UpdateNotificationsEnabled => false;
29-
3028
protected override Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
3129
{
3230
InteractionService.DisplayMessage(KnownEmojis.Information, CertificatesCommandStrings.CleanProgress);

src/Aspire.Cli/Commands/CertificatesTrustCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public CertificatesTrustCommand(ICertificateService certificateService, IInterac
2525
_certificateService = certificateService;
2626
}
2727

28-
protected override bool UpdateNotificationsEnabled => false;
29-
3028
protected override async Task<CommandResult> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
3129
{
3230
InteractionService.DisplayMessage(KnownEmojis.Information, CertificatesCommandStrings.TrustProgress);

0 commit comments

Comments
 (0)