Skip to content

Commit d8a8b60

Browse files
Copilotdavidfowl
andcommitted
Make commandName non-nullable in ConsoleActivityLogger
The commandName parameter is always provided from PipelineCommandBase.Name and should never be null. Changed constructor signature to make it a required parameter and removed null checks. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
1 parent a2313fd commit d8a8b60

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Aspire.Cli/Commands/PipelineCommandBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public async Task<bool> ProcessAndDisplayPublishingActivitiesAsync(IAsyncEnumera
410410
{
411411
var stepCounter = 1;
412412
var steps = new Dictionary<string, StepInfo>();
413-
var logger = new ConsoleActivityLogger(_hostEnvironment, commandName: this.Name);
413+
var logger = new ConsoleActivityLogger(_hostEnvironment, this.Name);
414414
logger.StartSpinner();
415415
PublishingActivity? publishingActivity = null;
416416

src/Aspire.Cli/Utils/ConsoleActivityLogger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal sealed class ConsoleActivityLogger
1818
{
1919
private readonly bool _enableColor;
2020
private readonly ICliHostEnvironment _hostEnvironment;
21-
private readonly string? _commandName;
21+
private readonly string _commandName;
2222
private readonly object _lock = new();
2323
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
2424
private readonly Dictionary<string, string> _stepColors = new();
@@ -44,7 +44,7 @@ internal sealed class ConsoleActivityLogger
4444
private const string InProgressSymbol = "→";
4545
private const string InfoSymbol = "i";
4646

47-
public ConsoleActivityLogger(ICliHostEnvironment hostEnvironment, bool? forceColor = null, string? commandName = null)
47+
public ConsoleActivityLogger(ICliHostEnvironment hostEnvironment, string commandName, bool? forceColor = null)
4848
{
4949
_hostEnvironment = hostEnvironment;
5050
_enableColor = forceColor ?? _hostEnvironment.SupportsAnsi;
@@ -256,7 +256,7 @@ public void WriteSummary()
256256
AnsiConsole.MarkupLine(_finalStatusHeader!);
257257

258258
// If pipeline failed, show help message about using --log-level debug
259-
if (!_pipelineSucceeded && !string.IsNullOrEmpty(_commandName))
259+
if (!_pipelineSucceeded)
260260
{
261261
var helpMessage = _enableColor
262262
? $"[dim]For more details, re-run with: aspire {_commandName} --log-level debug[/]"

0 commit comments

Comments
 (0)