From 35606d2cd04a7b1bec1d669f9619501dff2bf9dc Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 17:38:36 -0700 Subject: Simplify heat by creating a single executable --- src/heat/HelpCommand.cs | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/heat/HelpCommand.cs (limited to 'src/heat/HelpCommand.cs') diff --git a/src/heat/HelpCommand.cs b/src/heat/HelpCommand.cs new file mode 100644 index 00000000..bd2bcc24 --- /dev/null +++ b/src/heat/HelpCommand.cs @@ -0,0 +1,97 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Harvesters +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Diagnostics; + using System.Threading; + using System.Threading.Tasks; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + using WixToolset.Harvesters.Data; + using WixToolset.Harvesters.Extensibility; + + internal class HelpCommand : ICommandLineCommand + { + const string HelpMessageOptionFormat = " {0,-7} {1}"; + + public HelpCommand(IList extensions) + { + this.Extensions = extensions; + } + + private IList Extensions { get; } + + public bool ShowLogo => false; + + public bool StopParsing => true; + + public Task ExecuteAsync(CancellationToken cancellationToken) + { + var exitCode = this.DisplayHelp(); + return Task.FromResult(exitCode); + } + + public static void DisplayToolHeader() + { + var wixcopAssembly = typeof(HelpCommand).Assembly; + var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location); + + Console.WriteLine("WiX Toolset Harvester version {0}", fv.FileVersion); + Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved."); + Console.WriteLine(); + } + + public bool TryParseArgument(ICommandLineParser parser, string argument) => true; + + private int DisplayHelp() + { + DisplayToolHeader(); + + // output the harvest types alphabetically + SortedList harvestOptions = new SortedList(); + foreach (var heatExtension in this.Extensions) + { + foreach (HeatCommandLineOption commandLineOption in heatExtension.CommandLineTypes) + { + harvestOptions.Add(commandLineOption.Option, commandLineOption); + } + } + + harvestOptions.Add("-nologo", new HeatCommandLineOption("-nologo", "skip printing heat logo information")); + harvestOptions.Add("-indent ", new HeatCommandLineOption("-indent ", "indentation multiple (overrides default of 4)")); + harvestOptions.Add("-o[ut]", new HeatCommandLineOption("-out", "specify output file (default: write to current directory)")); + harvestOptions.Add("-sw", new HeatCommandLineOption("-sw", "suppress all warnings or a specific message ID\r\n (example: -sw1011 -sw1012)")); + harvestOptions.Add("-swall", new HeatCommandLineOption("-swall", "suppress all warnings (deprecated)")); + harvestOptions.Add("-v", new HeatCommandLineOption("-v", "verbose output")); + harvestOptions.Add("-wx[N]", new HeatCommandLineOption("-wx[N]", "treat all warnings or a specific message ID as an error\r\n (example: -wx1011 -wx1012)")); + harvestOptions.Add("-wxall", new HeatCommandLineOption("-wxall", "treat all warnings as errors (deprecated)")); + + foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values) + { + if (!commandLineOption.Option.StartsWith("-")) + { + Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description); + } + } + + Console.WriteLine(); + Console.WriteLine("Options:"); + + foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values) + { + if (commandLineOption.Option.StartsWith("-")) + { + Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description); + } + } + + Console.WriteLine(HelpMessageOptionFormat, "-? | -help", "this help information"); + Console.WriteLine("For more information see: https://wixtoolset.org/"); + + return 0; + } + } +} -- cgit v1.2.3-55-g6feb