diff options
Diffstat (limited to 'src/heat/HelpCommand.cs')
| -rw-r--r-- | src/heat/HelpCommand.cs | 97 |
1 files changed, 97 insertions, 0 deletions
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 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Harvesters | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections; | ||
| 7 | using System.Collections.Generic; | ||
| 8 | using System.Diagnostics; | ||
| 9 | using System.Threading; | ||
| 10 | using System.Threading.Tasks; | ||
| 11 | using WixToolset.Extensibility.Data; | ||
| 12 | using WixToolset.Extensibility.Services; | ||
| 13 | using WixToolset.Harvesters.Data; | ||
| 14 | using WixToolset.Harvesters.Extensibility; | ||
| 15 | |||
| 16 | internal class HelpCommand : ICommandLineCommand | ||
| 17 | { | ||
| 18 | const string HelpMessageOptionFormat = " {0,-7} {1}"; | ||
| 19 | |||
| 20 | public HelpCommand(IList<IHeatExtension> extensions) | ||
| 21 | { | ||
| 22 | this.Extensions = extensions; | ||
| 23 | } | ||
| 24 | |||
| 25 | private IList<IHeatExtension> Extensions { get; } | ||
| 26 | |||
| 27 | public bool ShowLogo => false; | ||
| 28 | |||
| 29 | public bool StopParsing => true; | ||
| 30 | |||
| 31 | public Task<int> ExecuteAsync(CancellationToken cancellationToken) | ||
| 32 | { | ||
| 33 | var exitCode = this.DisplayHelp(); | ||
| 34 | return Task.FromResult(exitCode); | ||
| 35 | } | ||
| 36 | |||
| 37 | public static void DisplayToolHeader() | ||
| 38 | { | ||
| 39 | var wixcopAssembly = typeof(HelpCommand).Assembly; | ||
| 40 | var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location); | ||
| 41 | |||
| 42 | Console.WriteLine("WiX Toolset Harvester version {0}", fv.FileVersion); | ||
| 43 | Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved."); | ||
| 44 | Console.WriteLine(); | ||
| 45 | } | ||
| 46 | |||
| 47 | public bool TryParseArgument(ICommandLineParser parser, string argument) => true; | ||
| 48 | |||
| 49 | private int DisplayHelp() | ||
| 50 | { | ||
| 51 | DisplayToolHeader(); | ||
| 52 | |||
| 53 | // output the harvest types alphabetically | ||
| 54 | SortedList harvestOptions = new SortedList(); | ||
| 55 | foreach (var heatExtension in this.Extensions) | ||
| 56 | { | ||
| 57 | foreach (HeatCommandLineOption commandLineOption in heatExtension.CommandLineTypes) | ||
| 58 | { | ||
| 59 | harvestOptions.Add(commandLineOption.Option, commandLineOption); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | harvestOptions.Add("-nologo", new HeatCommandLineOption("-nologo", "skip printing heat logo information")); | ||
| 64 | harvestOptions.Add("-indent <N>", new HeatCommandLineOption("-indent <N>", "indentation multiple (overrides default of 4)")); | ||
| 65 | harvestOptions.Add("-o[ut]", new HeatCommandLineOption("-out", "specify output file (default: write to current directory)")); | ||
| 66 | harvestOptions.Add("-sw<N>", new HeatCommandLineOption("-sw<N>", "suppress all warnings or a specific message ID\r\n (example: -sw1011 -sw1012)")); | ||
| 67 | harvestOptions.Add("-swall", new HeatCommandLineOption("-swall", "suppress all warnings (deprecated)")); | ||
| 68 | harvestOptions.Add("-v", new HeatCommandLineOption("-v", "verbose output")); | ||
| 69 | harvestOptions.Add("-wx[N]", new HeatCommandLineOption("-wx[N]", "treat all warnings or a specific message ID as an error\r\n (example: -wx1011 -wx1012)")); | ||
| 70 | harvestOptions.Add("-wxall", new HeatCommandLineOption("-wxall", "treat all warnings as errors (deprecated)")); | ||
| 71 | |||
| 72 | foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values) | ||
| 73 | { | ||
| 74 | if (!commandLineOption.Option.StartsWith("-")) | ||
| 75 | { | ||
| 76 | Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | Console.WriteLine(); | ||
| 81 | Console.WriteLine("Options:"); | ||
| 82 | |||
| 83 | foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values) | ||
| 84 | { | ||
| 85 | if (commandLineOption.Option.StartsWith("-")) | ||
| 86 | { | ||
| 87 | Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | Console.WriteLine(HelpMessageOptionFormat, "-? | -help", "this help information"); | ||
| 92 | Console.WriteLine("For more information see: https://wixtoolset.org/"); | ||
| 93 | |||
| 94 | return 0; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | } | ||
