From a6f8b6fa3903d846cdc2fbe715ca951d83af3107 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 11 Aug 2022 17:40:06 -0700 Subject: Redesign command-line help to meet the needs of WiX v4 --- src/tools/heat/HeatCommand.cs | 22 +++++++++++++--------- src/tools/heat/HeatCommandLine.cs | 6 ++---- src/tools/heat/HelpCommand.cs | 17 +++++++---------- 3 files changed, 22 insertions(+), 23 deletions(-) (limited to 'src/tools') diff --git a/src/tools/heat/HeatCommand.cs b/src/tools/heat/HeatCommand.cs index 56277004..6815acd6 100644 --- a/src/tools/heat/HeatCommand.cs +++ b/src/tools/heat/HeatCommand.cs @@ -11,13 +11,16 @@ namespace WixToolset.Harvesters using System.Threading.Tasks; using System.Xml; using WixToolset.Data; + using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; using WixToolset.Harvesters.Extensibility; using Wix = WixToolset.Harvesters.Serialize; - internal class HeatCommand : ICommandLineCommand + internal class HeatCommand : BaseCommandLineCommand { + private bool showLogo; + public HeatCommand(string harvestType, IList extensions, IServiceProvider serviceProvider) { this.Extensions = extensions; @@ -28,11 +31,7 @@ namespace WixToolset.Harvesters this.ExtensionOptions.Add(harvestType); } - public bool ShowHelp { get; set; } - - public bool ShowLogo { get; set; } - - public bool StopParsing { get; private set; } + public override bool ShowLogo => this.showLogo; private string ExtensionArgument { get; set; } @@ -50,13 +49,18 @@ namespace WixToolset.Harvesters private IServiceProvider ServiceProvider { get; } - public Task ExecuteAsync(CancellationToken cancellationToken) + public override CommandLineHelp GetCommandLineHelp() + { + return null; + } + + public override Task ExecuteAsync(CancellationToken cancellationToken) { var exitCode = this.Harvest(); return Task.FromResult(exitCode); } - public bool TryParseArgument(ICommandLineParser parser, string arg) + public override bool TryParseArgument(ICommandLineParser parser, string arg) { if (this.ExtensionArgument == null) { @@ -67,7 +71,7 @@ namespace WixToolset.Harvesters string parameter = arg.Substring(1); if ("nologo" == parameter) { - this.ShowLogo = false; + this.showLogo = false; } else if ("o" == parameter || "out" == parameter) { diff --git a/src/tools/heat/HeatCommandLine.cs b/src/tools/heat/HeatCommandLine.cs index b11dda4e..f299266d 100644 --- a/src/tools/heat/HeatCommandLine.cs +++ b/src/tools/heat/HeatCommandLine.cs @@ -13,19 +13,17 @@ namespace WixToolset.Harvesters internal class HeatCommandLine : IHeatCommandLine { - private readonly List extensions; - private readonly IMessaging messaging; private readonly IServiceProvider serviceProvider; + private readonly List extensions; public HeatCommandLine(IServiceProvider serviceProvider, IEnumerable heatExtensions) { + this.serviceProvider = serviceProvider; this.extensions = new List { new IIsHeatExtension(), new UtilHeatExtension(serviceProvider), new VSHeatExtension() }; if (heatExtensions != null) { this.extensions.AddRange(heatExtensions); } - this.messaging = serviceProvider.GetService(); - this.serviceProvider = serviceProvider; } public ICommandLineCommand ParseStandardCommandLine(ICommandLineArguments arguments) diff --git a/src/tools/heat/HelpCommand.cs b/src/tools/heat/HelpCommand.cs index d991b4fa..25d8cd87 100644 --- a/src/tools/heat/HelpCommand.cs +++ b/src/tools/heat/HelpCommand.cs @@ -8,12 +8,13 @@ namespace WixToolset.Harvesters using System.Diagnostics; using System.Threading; using System.Threading.Tasks; + using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; using WixToolset.Harvesters.Data; using WixToolset.Harvesters.Extensibility; - internal class HelpCommand : ICommandLineCommand + internal class HelpCommand : BaseCommandLineCommand { const string HelpMessageOptionFormat = " {0,-7} {1}"; @@ -24,17 +25,12 @@ namespace WixToolset.Harvesters private IList Extensions { get; } - public bool ShowHelp { get; set; } - - public bool ShowLogo + public override CommandLineHelp GetCommandLineHelp() { - get => false; - set { } + return null; } - public bool StopParsing => true; - - public Task ExecuteAsync(CancellationToken cancellationToken) + public override Task ExecuteAsync(CancellationToken cancellationToken) { var exitCode = this.DisplayHelp(); return Task.FromResult(exitCode); @@ -50,8 +46,9 @@ namespace WixToolset.Harvesters Console.WriteLine(); } - public bool TryParseArgument(ICommandLineParser parser, string argument) + public override bool TryParseArgument(ICommandLineParser parser, string argument) { + this.StopParsing = true; return true; } -- cgit v1.2.3-55-g6feb