summaryrefslogtreecommitdiff
path: root/src/tools/heat/HelpCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/heat/HelpCommand.cs')
-rw-r--r--src/tools/heat/HelpCommand.cs106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/tools/heat/HelpCommand.cs b/src/tools/heat/HelpCommand.cs
new file mode 100644
index 00000000..d991b4fa
--- /dev/null
+++ b/src/tools/heat/HelpCommand.cs
@@ -0,0 +1,106 @@
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
3namespace 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 ShowHelp { get; set; }
28
29 public bool ShowLogo
30 {
31 get => false;
32 set { }
33 }
34
35 public bool StopParsing => true;
36
37 public Task<int> ExecuteAsync(CancellationToken cancellationToken)
38 {
39 var exitCode = this.DisplayHelp();
40 return Task.FromResult(exitCode);
41 }
42
43 public static void DisplayToolHeader()
44 {
45 var wixcopAssembly = typeof(HelpCommand).Assembly;
46 var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location);
47
48 Console.WriteLine("WiX Toolset Harvester version {0}", fv.ProductVersion);
49 Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved.");
50 Console.WriteLine();
51 }
52
53 public bool TryParseArgument(ICommandLineParser parser, string argument)
54 {
55 return true;
56 }
57
58 private int DisplayHelp()
59 {
60 DisplayToolHeader();
61
62 // output the harvest types alphabetically
63 SortedList harvestOptions = new SortedList();
64 foreach (var heatExtension in this.Extensions)
65 {
66 foreach (HeatCommandLineOption commandLineOption in heatExtension.CommandLineTypes)
67 {
68 harvestOptions.Add(commandLineOption.Option, commandLineOption);
69 }
70 }
71
72 harvestOptions.Add("-nologo", new HeatCommandLineOption("-nologo", "skip printing heat logo information"));
73 harvestOptions.Add("-indent <N>", new HeatCommandLineOption("-indent <N>", "indentation multiple (overrides default of 4)"));
74 harvestOptions.Add("-o[ut]", new HeatCommandLineOption("-out", "specify output file (default: write to current directory)"));
75 harvestOptions.Add("-sw<N>", new HeatCommandLineOption("-sw<N>", "suppress all warnings or a specific message ID\r\n (example: -sw1011 -sw1012)"));
76 harvestOptions.Add("-swall", new HeatCommandLineOption("-swall", "suppress all warnings (deprecated)"));
77 harvestOptions.Add("-v", new HeatCommandLineOption("-v", "verbose output"));
78 harvestOptions.Add("-wx[N]", new HeatCommandLineOption("-wx[N]", "treat all warnings or a specific message ID as an error\r\n (example: -wx1011 -wx1012)"));
79 harvestOptions.Add("-wxall", new HeatCommandLineOption("-wxall", "treat all warnings as errors (deprecated)"));
80
81 foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values)
82 {
83 if (!commandLineOption.Option.StartsWith("-"))
84 {
85 Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description);
86 }
87 }
88
89 Console.WriteLine();
90 Console.WriteLine("Options:");
91
92 foreach (HeatCommandLineOption commandLineOption in harvestOptions.Values)
93 {
94 if (commandLineOption.Option.StartsWith("-"))
95 {
96 Console.WriteLine(HelpMessageOptionFormat, commandLineOption.Option, commandLineOption.Description);
97 }
98 }
99
100 Console.WriteLine(HelpMessageOptionFormat, "-? | -help", "this help information");
101 Console.WriteLine("For more information see: https://wixtoolset.org/");
102
103 return 0;
104 }
105 }
106}