Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 11 additions & 2 deletions src/Cake.Cli/Hosts/BuildScriptHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Core.Configuration;
using Cake.Core.Diagnostics;
using Cake.Core.Scripting;

Expand All @@ -22,13 +24,15 @@ public sealed class BuildScriptHost : BuildScriptHost<ICakeContext>
/// <param name="executionStrategy">The execution strategy.</param>
/// <param name="context">The context.</param>
/// <param name="reportPrinter">The report printer.</param>
/// <param name="configuration">The Cake Configuration.</param>
/// <param name="log">The log.</param>
public BuildScriptHost(
ICakeEngine engine,
IExecutionStrategy executionStrategy,
ICakeContext context,
ICakeReportPrinter reportPrinter,
ICakeLog log) : base(engine, executionStrategy, context, reportPrinter, log)
ICakeConfiguration configuration,
ICakeLog log) : base(engine, executionStrategy, context, reportPrinter, configuration, log)
{
}
}
Expand All @@ -44,6 +48,7 @@ public class BuildScriptHost<TContext> : ScriptHost
private readonly ICakeLog _log;
private readonly IExecutionStrategy _executionStrategy;
private readonly TContext _context;
private readonly ICakeConfiguration _configuration;

/// <summary>
/// Initializes a new instance of the <see cref="BuildScriptHost{TContext}"/> class.
Expand All @@ -52,17 +57,20 @@ public class BuildScriptHost<TContext> : ScriptHost
/// <param name="executionStrategy">The execution strategy.</param>
/// <param name="context">The context.</param>
/// <param name="reportPrinter">The report printer.</param>
/// <param name="configuration">The Cake Configuration.</param>
/// <param name="log">The log.</param>
public BuildScriptHost(
ICakeEngine engine,
IExecutionStrategy executionStrategy,
TContext context,
ICakeReportPrinter reportPrinter,
ICakeConfiguration configuration,
ICakeLog log) : base(engine, context)
{
_executionStrategy = executionStrategy;
_context = context;
_reportPrinter = reportPrinter;
_configuration = configuration;
_log = log;
}

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

if (report != null && !report.IsEmpty)
var noReportEnabled = _configuration.GetValue("Settings_NoReport") ?? bool.FalseString;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devlead I tried to use the Constants class here, rather than the hard coded Settings_NoReport, but it is marked internal. Should I create a new Constants class in the Cake.Cli project?

if (report != null && !report.IsEmpty && !noReportEnabled.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
{
_reportPrinter.Write(report);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Cake/Commands/DefaultCommandSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,12 @@ public sealed class DefaultCommandSettings : CommandSettings
[CommandOption("--" + Infrastructure.Constants.Cache.InvalidateScriptCache)]
[Description("Forces the script to be recompiled if caching is enabled.")]
public bool Recompile { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to display report summary at the end of Cake execution.
/// </summary>
[CommandOption("--" + Infrastructure.Constants.CakeExecution.NoReport)]
[Description("Prevent the display of the summary report at the end of Cake Execution.")]
public bool NoReport { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Cake/Infrastructure/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static class Settings
{
public const string EnableScriptCache = "Settings_EnableScriptCache";
public const string UseSpectreConsoleForConsoleOutput = "Settings_UseSpectreConsoleForConsoleOutput";
public const string NoReport = "Settings_NoReport";
}

public static class Paths
Expand All @@ -21,5 +22,10 @@ public static class Cache
{
public const string InvalidateScriptCache = "invalidate-script-cache";
}

public static class CakeExecution
{
public const string NoReport = "no-report";
}
}
}