From 6a4a3d4cf929b97de2129777926faddf8bea5b12 Mon Sep 17 00:00:00 2001 From: Sean Fausett Date: Fri, 22 Feb 2019 18:49:26 +1300 Subject: [PATCH] Add global override to show process command-line --- src/Cake.Core/Constants.cs | 1 + src/Cake.Core/IO/ProcessRunner.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Cake.Core/Constants.cs b/src/Cake.Core/Constants.cs index 2bd89965d6..af33bf7206 100644 --- a/src/Cake.Core/Constants.cs +++ b/src/Cake.Core/Constants.cs @@ -16,6 +16,7 @@ public static class Settings public const string SkipVerification = "Settings_SkipVerification"; public const string SkipPackageVersionCheck = "Settings_SkipPackageVersionCheck"; public const string NoMonoCoersion = "Settings_NoMonoCoersion"; + public const string ShowProcessCommandLine = "Settings_ShowProcessCommandLine"; } public static class Paths diff --git a/src/Cake.Core/IO/ProcessRunner.cs b/src/Cake.Core/IO/ProcessRunner.cs index 4777b9c07a..286db50b83 100644 --- a/src/Cake.Core/IO/ProcessRunner.cs +++ b/src/Cake.Core/IO/ProcessRunner.cs @@ -23,6 +23,7 @@ public sealed class ProcessRunner : IProcessRunner private readonly IToolLocator _tools; private readonly ICakeConfiguration _configuration; private readonly bool _noMonoCoersion; + private readonly bool _showCommandLine; /// /// Initializes a new instance of the class. @@ -42,6 +43,8 @@ public ProcessRunner(IFileSystem fileSystem, ICakeEnvironment environment, ICake var noMonoCoersion = configuration.GetValue(Constants.Settings.NoMonoCoersion); _noMonoCoersion = noMonoCoersion != null && noMonoCoersion.Equals("true", StringComparison.OrdinalIgnoreCase); + var showCommandLine = configuration.GetValue(Constants.Settings.ShowProcessCommandLine); + _showCommandLine = showCommandLine != null && showCommandLine.Equals("true", StringComparison.OrdinalIgnoreCase); } /// @@ -123,9 +126,12 @@ internal ProcessStartInfo GetProcessStartInfo(FilePath filePath, ProcessSettings if (!settings.Silent) { - // Log the filename and arguments. - var message = string.Concat(fileName, " ", arguments.RenderSafe().TrimEnd()); - _log.Verbose(Verbosity.Diagnostic, "Executing: {0}", message); + using (_log.WithVerbosity(_showCommandLine ? Verbosity.Diagnostic : _log.Verbosity)) + { + // Log the filename and arguments. + var message = string.Concat(fileName, " ", arguments.RenderSafe().TrimEnd()); + _log.Verbose(Verbosity.Diagnostic, "Executing: {0}", message); + } } // Create the process start info.