Skip to content

Commit 1ea2f39

Browse files
committed
(#2101) Allow report summary to not be shown
As part of a normal Cake execution, a report summary is always shown at the end. This includes information about what tasks were ran, how long they took, etc. However, there are those that don't want to allow this to happen. This commit introduces a new configuration option, which allows the report summary to not be shown. This can be done in the usual way with a command line parameter, cake.config file entry, or an environment variable.
1 parent f20ad25 commit 1ea2f39

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Cake.Cli/Hosts/BuildScriptHost.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Collections.Generic;
67
using System.Threading.Tasks;
78
using Cake.Core;
9+
using Cake.Core.Configuration;
810
using Cake.Core.Diagnostics;
911
using Cake.Core.Scripting;
1012

@@ -22,13 +24,15 @@ public sealed class BuildScriptHost : BuildScriptHost<ICakeContext>
2224
/// <param name="executionStrategy">The execution strategy.</param>
2325
/// <param name="context">The context.</param>
2426
/// <param name="reportPrinter">The report printer.</param>
27+
/// <param name="configuration">The Cake Configuration.</param>
2528
/// <param name="log">The log.</param>
2629
public BuildScriptHost(
2730
ICakeEngine engine,
2831
IExecutionStrategy executionStrategy,
2932
ICakeContext context,
3033
ICakeReportPrinter reportPrinter,
31-
ICakeLog log) : base(engine, executionStrategy, context, reportPrinter, log)
34+
ICakeConfiguration configuration,
35+
ICakeLog log) : base(engine, executionStrategy, context, reportPrinter, configuration, log)
3236
{
3337
}
3438
}
@@ -44,6 +48,7 @@ public class BuildScriptHost<TContext> : ScriptHost
4448
private readonly ICakeLog _log;
4549
private readonly IExecutionStrategy _executionStrategy;
4650
private readonly TContext _context;
51+
private readonly ICakeConfiguration _configuration;
4752

4853
/// <summary>
4954
/// Initializes a new instance of the <see cref="BuildScriptHost{TContext}"/> class.
@@ -58,11 +63,13 @@ public BuildScriptHost(
5863
IExecutionStrategy executionStrategy,
5964
TContext context,
6065
ICakeReportPrinter reportPrinter,
66+
ICakeConfiguration configuration,
6167
ICakeLog log) : base(engine, context)
6268
{
6369
_executionStrategy = executionStrategy;
6470
_context = context;
6571
_reportPrinter = reportPrinter;
72+
_configuration = configuration;
6673
_log = log;
6774
}
6875

@@ -88,7 +95,8 @@ private async Task<CakeReport> internalRunTargetAsync()
8895
{
8996
var report = await Engine.RunTargetAsync(_context, _executionStrategy, Settings).ConfigureAwait(false);
9097

91-
if (report != null && !report.IsEmpty)
98+
var noReportEnabled = _configuration.GetValue("Settings_NoReport") ?? bool.FalseString;
99+
if (report != null && !report.IsEmpty && !noReportEnabled.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
92100
{
93101
_reportPrinter.Write(report);
94102
}

src/Cake/Commands/DefaultCommandSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,9 @@ public sealed class DefaultCommandSettings : CommandSettings
102102
[CommandOption("--" + Infrastructure.Constants.Cache.InvalidateScriptCache)]
103103
[Description("Forces the script to be recompiled if caching is enabled.")]
104104
public bool Recompile { get; set; }
105+
106+
[CommandOption("--" + Infrastructure.Constants.CakeExecution.NoReport)]
107+
[Description("Prevent the display of the summary report at the end of Cake Execution.")]
108+
public bool NoReport { get; set;}
105109
}
106110
}

src/Cake/Infrastructure/Constants.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static class Settings
1010
{
1111
public const string EnableScriptCache = "Settings_EnableScriptCache";
1212
public const string UseSpectreConsoleForConsoleOutput = "Settings_UseSpectreConsoleForConsoleOutput";
13+
public const string NoReport = "Settings_NoReport";
1314
}
1415

1516
public static class Paths
@@ -21,5 +22,10 @@ public static class Cache
2122
{
2223
public const string InvalidateScriptCache = "invalidate-script-cache";
2324
}
25+
26+
public static class CakeExecution
27+
{
28+
public const string NoReport = "no-report";
29+
}
2430
}
2531
}

0 commit comments

Comments
 (0)