diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-01-08 05:51:26 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-01-10 17:08:43 -0800 |
| commit | 02ee982cf4ceabd64dbe966dc3771d272d53a085 (patch) | |
| tree | 820d685014ac0fb20b0493d4a05cfd9fe2baa5d0 /src | |
| parent | a96db4a508f1d1774500ab89f2c57e581fb5a13a (diff) | |
| download | wix-02ee982cf4ceabd64dbe966dc3771d272d53a085.tar.gz wix-02ee982cf4ceabd64dbe966dc3771d272d53a085.tar.bz2 wix-02ee982cf4ceabd64dbe966dc3771d272d53a085.zip | |
Centralize common command-line switches parsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs | 7 | ||||
| -rw-r--r-- | src/wix/WixToolset.Converters/FixupCommandBase.cs | 6 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManagerCommand.cs | 6 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/BuildCommand.cs | 82 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/CommandLine.cs | 87 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/CompileCommand.cs | 19 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/DecompileCommand.cs | 82 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/HelpCommand.cs | 17 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core/CommandLine/VersionCommand.cs | 9 | ||||
| -rw-r--r-- | src/wix/heat/HeatCommand.cs | 10 | ||||
| -rw-r--r-- | src/wix/heat/HelpCommand.cs | 15 |
11 files changed, 177 insertions, 163 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs index b03a18f4..b6c9ef3e 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs | |||
| @@ -12,9 +12,14 @@ namespace WixToolset.Extensibility.Data | |||
| 12 | public interface ICommandLineCommand | 12 | public interface ICommandLineCommand |
| 13 | { | 13 | { |
| 14 | /// <summary> | 14 | /// <summary> |
| 15 | /// Indicates the command-line should show help for the command. | ||
| 16 | /// </summary> | ||
| 17 | bool ShowHelp { get; set; } | ||
| 18 | |||
| 19 | /// <summary> | ||
| 15 | /// Indicates the command-line should show the command-line logo. | 20 | /// Indicates the command-line should show the command-line logo. |
| 16 | /// </summary> | 21 | /// </summary> |
| 17 | bool ShowLogo { get; } | 22 | bool ShowLogo { get; set; } |
| 18 | 23 | ||
| 19 | /// <summary> | 24 | /// <summary> |
| 20 | /// Indicates the command-line parsing can stop. | 25 | /// Indicates the command-line parsing can stop. |
diff --git a/src/wix/WixToolset.Converters/FixupCommandBase.cs b/src/wix/WixToolset.Converters/FixupCommandBase.cs index 21282d07..71d4dad7 100644 --- a/src/wix/WixToolset.Converters/FixupCommandBase.cs +++ b/src/wix/WixToolset.Converters/FixupCommandBase.cs | |||
| @@ -23,11 +23,11 @@ namespace WixToolset.Converters | |||
| 23 | this.SearchPatterns = new List<string>(); | 23 | this.SearchPatterns = new List<string>(); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | public bool ShowLogo { get; private set; } | 26 | public bool ShowHelp { get; set; } |
| 27 | 27 | ||
| 28 | public bool StopParsing { get; private set; } | 28 | public bool ShowLogo { get; set; } |
| 29 | 29 | ||
| 30 | protected bool ShowHelp { get; set; } | 30 | public bool StopParsing { get; set; } |
| 31 | 31 | ||
| 32 | protected CustomTableTarget CustomTableSetting { get; set; } | 32 | protected CustomTableTarget CustomTableSetting { get; set; } |
| 33 | 33 | ||
diff --git a/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManagerCommand.cs b/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManagerCommand.cs index 94ee4f22..d37ee341 100644 --- a/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManagerCommand.cs +++ b/src/wix/WixToolset.Core.ExtensionCache/ExtensionCacheManagerCommand.cs | |||
| @@ -30,11 +30,11 @@ namespace WixToolset.Core.ExtensionCache | |||
| 30 | 30 | ||
| 31 | private IMessaging Messaging { get; } | 31 | private IMessaging Messaging { get; } |
| 32 | 32 | ||
| 33 | public bool ShowLogo { get; private set; } | 33 | public bool ShowHelp { get; set; } |
| 34 | 34 | ||
| 35 | public bool StopParsing { get; private set; } | 35 | public bool ShowLogo { get; set; } |
| 36 | 36 | ||
| 37 | private bool ShowHelp { get; set; } | 37 | public bool StopParsing { get; set; } |
| 38 | 38 | ||
| 39 | private bool Global { get; set; } | 39 | private bool Global { get; set; } |
| 40 | 40 | ||
diff --git a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs index 47b7afa8..3ea47279 100644 --- a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -26,8 +26,19 @@ namespace WixToolset.Core.CommandLine | |||
| 26 | this.commandLine = new CommandLine(this.ServiceProvider, this.Messaging); | 26 | this.commandLine = new CommandLine(this.ServiceProvider, this.Messaging); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | public bool ShowLogo => this.commandLine.ShowLogo; | 29 | public bool ShowHelp |
| 30 | { | ||
| 31 | get { return this.commandLine.ShowHelp; } | ||
| 32 | set { this.commandLine.ShowHelp = value; } | ||
| 33 | } | ||
| 34 | |||
| 35 | public bool ShowLogo | ||
| 36 | { | ||
| 37 | get { return this.commandLine.ShowLogo; } | ||
| 38 | set { this.commandLine.ShowLogo = value; } | ||
| 39 | } | ||
| 30 | 40 | ||
| 41 | // Stop parsing when we've decided to show help. | ||
| 31 | public bool StopParsing => this.commandLine.ShowHelp; | 42 | public bool StopParsing => this.commandLine.ShowHelp; |
| 32 | 43 | ||
| 33 | private IServiceProvider ServiceProvider { get; } | 44 | private IServiceProvider ServiceProvider { get; } |
| @@ -515,9 +526,9 @@ namespace WixToolset.Core.CommandLine | |||
| 515 | 526 | ||
| 516 | public PdbType PdbType { get; private set; } | 527 | public PdbType PdbType { get; private set; } |
| 517 | 528 | ||
| 518 | public bool ShowLogo { get; private set; } | 529 | public bool ShowLogo { get; set; } |
| 519 | 530 | ||
| 520 | public bool ShowHelp { get; private set; } | 531 | public bool ShowHelp { get; set; } |
| 521 | 532 | ||
| 522 | public string IntermediateFolder { get; private set; } | 533 | public string IntermediateFolder { get; private set; } |
| 523 | 534 | ||
| @@ -554,12 +565,6 @@ namespace WixToolset.Core.CommandLine | |||
| 554 | var parameter = arg.Substring(1).ToLowerInvariant(); | 565 | var parameter = arg.Substring(1).ToLowerInvariant(); |
| 555 | switch (parameter) | 566 | switch (parameter) |
| 556 | { | 567 | { |
| 557 | case "?": | ||
| 558 | case "h": | ||
| 559 | case "help": | ||
| 560 | this.ShowHelp = true; | ||
| 561 | return true; | ||
| 562 | |||
| 563 | case "arch": | 568 | case "arch": |
| 564 | case "platform": | 569 | case "platform": |
| 565 | { | 570 | { |
| @@ -672,15 +677,6 @@ namespace WixToolset.Core.CommandLine | |||
| 672 | return true; | 677 | return true; |
| 673 | } | 678 | } |
| 674 | 679 | ||
| 675 | case "nologo": | ||
| 676 | this.ShowLogo = false; | ||
| 677 | return true; | ||
| 678 | |||
| 679 | case "v": | ||
| 680 | case "verbose": | ||
| 681 | this.Messaging.ShowVerboseMessages = true; | ||
| 682 | return true; | ||
| 683 | |||
| 684 | case "sval": | 680 | case "sval": |
| 685 | this.SuppressValidation = true; | 681 | this.SuppressValidation = true; |
| 686 | return true; | 682 | return true; |
| @@ -690,22 +686,6 @@ namespace WixToolset.Core.CommandLine | |||
| 690 | return true; | 686 | return true; |
| 691 | } | 687 | } |
| 692 | 688 | ||
| 693 | if (parameter.StartsWith("sw")) | ||
| 694 | { | ||
| 695 | this.ParseSuppressWarning(parameter, "sw".Length, parser); | ||
| 696 | return true; | ||
| 697 | } | ||
| 698 | else if (parameter.StartsWith("suppresswarning")) | ||
| 699 | { | ||
| 700 | this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); | ||
| 701 | return true; | ||
| 702 | } | ||
| 703 | else if (parameter.StartsWith("wx")) | ||
| 704 | { | ||
| 705 | this.ParseWarningAsError(parameter, "wx".Length, parser); | ||
| 706 | return true; | ||
| 707 | } | ||
| 708 | |||
| 709 | return false; | 689 | return false; |
| 710 | } | 690 | } |
| 711 | else | 691 | else |
| @@ -851,40 +831,6 @@ namespace WixToolset.Core.CommandLine | |||
| 851 | 831 | ||
| 852 | return true; | 832 | return true; |
| 853 | } | 833 | } |
| 854 | |||
| 855 | private void ParseSuppressWarning(string parameter, int offset, ICommandLineParser parser) | ||
| 856 | { | ||
| 857 | var paramArg = parameter.Substring(offset); | ||
| 858 | if (paramArg.Length == 0) | ||
| 859 | { | ||
| 860 | this.Messaging.SuppressAllWarnings = true; | ||
| 861 | } | ||
| 862 | else if (Int32.TryParse(paramArg, out var suppressWarning) && suppressWarning > 0) | ||
| 863 | { | ||
| 864 | this.Messaging.SuppressWarningMessage(suppressWarning); | ||
| 865 | } | ||
| 866 | else | ||
| 867 | { | ||
| 868 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalSuppressWarningId(paramArg)); | ||
| 869 | } | ||
| 870 | } | ||
| 871 | |||
| 872 | private void ParseWarningAsError(string parameter, int offset, ICommandLineParser parser) | ||
| 873 | { | ||
| 874 | var paramArg = parameter.Substring(offset); | ||
| 875 | if (paramArg.Length == 0) | ||
| 876 | { | ||
| 877 | this.Messaging.WarningsAsError = true; | ||
| 878 | } | ||
| 879 | else if (Int32.TryParse(paramArg, out var elevateWarning) && elevateWarning > 0) | ||
| 880 | { | ||
| 881 | this.Messaging.ElevateWarningMessage(elevateWarning); | ||
| 882 | } | ||
| 883 | else | ||
| 884 | { | ||
| 885 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalWarningIdAsError(paramArg)); | ||
| 886 | } | ||
| 887 | } | ||
| 888 | } | 834 | } |
| 889 | } | 835 | } |
| 890 | } | 836 | } |
diff --git a/src/wix/WixToolset.Core/CommandLine/CommandLine.cs b/src/wix/WixToolset.Core/CommandLine/CommandLine.cs index 73a82dfc..8913828b 100644 --- a/src/wix/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/wix/WixToolset.Core/CommandLine/CommandLine.cs | |||
| @@ -4,6 +4,7 @@ namespace WixToolset.Core.CommandLine | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using WixToolset.Data; | ||
| 7 | using WixToolset.Extensibility; | 8 | using WixToolset.Extensibility; |
| 8 | using WixToolset.Extensibility.Data; | 9 | using WixToolset.Extensibility.Data; |
| 9 | using WixToolset.Extensibility.Services; | 10 | using WixToolset.Extensibility.Services; |
| @@ -21,10 +22,16 @@ namespace WixToolset.Core.CommandLine | |||
| 21 | 22 | ||
| 22 | internal class CommandLine : ICommandLine | 23 | internal class CommandLine : ICommandLine |
| 23 | { | 24 | { |
| 24 | public CommandLine(IServiceProvider serviceProvider) => this.ServiceProvider = serviceProvider; | 25 | public CommandLine(IServiceProvider serviceProvider) |
| 26 | { | ||
| 27 | this.ServiceProvider = serviceProvider; | ||
| 28 | this.Messaging = serviceProvider.GetService<IMessaging>(); | ||
| 29 | } | ||
| 25 | 30 | ||
| 26 | private IServiceProvider ServiceProvider { get; } | 31 | private IServiceProvider ServiceProvider { get; } |
| 27 | 32 | ||
| 33 | private IMessaging Messaging { get; } | ||
| 34 | |||
| 28 | public ICommandLineCommand CreateCommand(string[] args) | 35 | public ICommandLineCommand CreateCommand(string[] args) |
| 29 | { | 36 | { |
| 30 | var arguments = this.ServiceProvider.GetService<ICommandLineArguments>(); | 37 | var arguments = this.ServiceProvider.GetService<ICommandLineArguments>(); |
| @@ -105,7 +112,8 @@ namespace WixToolset.Core.CommandLine | |||
| 105 | } | 112 | } |
| 106 | else if (parser.IsSwitch(arg)) | 113 | else if (parser.IsSwitch(arg)) |
| 107 | { | 114 | { |
| 108 | if (!command.TryParseArgument(parser, arg) && !TryParseCommandLineArgumentWithExtension(arg, parser, extensions)) | 115 | if (!command.TryParseArgument(parser, arg) && !TryParseCommandLineArgumentWithExtension(arg, parser, extensions) && |
| 116 | !this.TryParseStandardCommandLineSwitch(command, parser, arg)) | ||
| 109 | { | 117 | { |
| 110 | parser.ReportErrorArgument(arg); | 118 | parser.ReportErrorArgument(arg); |
| 111 | } | 119 | } |
| @@ -195,5 +203,80 @@ namespace WixToolset.Core.CommandLine | |||
| 195 | 203 | ||
| 196 | return false; | 204 | return false; |
| 197 | } | 205 | } |
| 206 | |||
| 207 | private bool TryParseStandardCommandLineSwitch(ICommandLineCommand command, ICommandLineParser parser, string arg) | ||
| 208 | { | ||
| 209 | var parameter = arg.Substring(1).ToLowerInvariant(); | ||
| 210 | |||
| 211 | switch (parameter) | ||
| 212 | { | ||
| 213 | case "?": | ||
| 214 | case "h": | ||
| 215 | case "help": | ||
| 216 | command.ShowHelp = true; | ||
| 217 | return true; | ||
| 218 | |||
| 219 | case "nologo": | ||
| 220 | command.ShowLogo = false; | ||
| 221 | return true; | ||
| 222 | |||
| 223 | case "v": | ||
| 224 | case "verbose": | ||
| 225 | this.Messaging.ShowVerboseMessages = true; | ||
| 226 | return true; | ||
| 227 | } | ||
| 228 | |||
| 229 | if (parameter.StartsWith("sw")) | ||
| 230 | { | ||
| 231 | this.ParseSuppressWarning(parameter, "sw".Length, parser); | ||
| 232 | return true; | ||
| 233 | } | ||
| 234 | else if (parameter.StartsWith("suppresswarning")) | ||
| 235 | { | ||
| 236 | this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); | ||
| 237 | return true; | ||
| 238 | } | ||
| 239 | else if (parameter.StartsWith("wx")) | ||
| 240 | { | ||
| 241 | this.ParseWarningAsError(parameter, "wx".Length, parser); | ||
| 242 | return true; | ||
| 243 | } | ||
| 244 | |||
| 245 | return false; | ||
| 246 | } | ||
| 247 | |||
| 248 | private void ParseSuppressWarning(string parameter, int offset, ICommandLineParser parser) | ||
| 249 | { | ||
| 250 | var paramArg = parameter.Substring(offset); | ||
| 251 | if (paramArg.Length == 0) | ||
| 252 | { | ||
| 253 | this.Messaging.SuppressAllWarnings = true; | ||
| 254 | } | ||
| 255 | else if (Int32.TryParse(paramArg, out var suppressWarning) && suppressWarning > 0) | ||
| 256 | { | ||
| 257 | this.Messaging.SuppressWarningMessage(suppressWarning); | ||
| 258 | } | ||
| 259 | else | ||
| 260 | { | ||
| 261 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalSuppressWarningId(paramArg)); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | private void ParseWarningAsError(string parameter, int offset, ICommandLineParser parser) | ||
| 266 | { | ||
| 267 | var paramArg = parameter.Substring(offset); | ||
| 268 | if (paramArg.Length == 0) | ||
| 269 | { | ||
| 270 | this.Messaging.WarningsAsError = true; | ||
| 271 | } | ||
| 272 | else if (Int32.TryParse(paramArg, out var elevateWarning) && elevateWarning > 0) | ||
| 273 | { | ||
| 274 | this.Messaging.ElevateWarningMessage(elevateWarning); | ||
| 275 | } | ||
| 276 | else | ||
| 277 | { | ||
| 278 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalWarningIdAsError(paramArg)); | ||
| 279 | } | ||
| 280 | } | ||
| 198 | } | 281 | } |
| 199 | } | 282 | } |
diff --git a/src/wix/WixToolset.Core/CommandLine/CompileCommand.cs b/src/wix/WixToolset.Core/CommandLine/CompileCommand.cs index 6e31b241..73e5bcbe 100644 --- a/src/wix/WixToolset.Core/CommandLine/CompileCommand.cs +++ b/src/wix/WixToolset.Core/CommandLine/CompileCommand.cs | |||
| @@ -30,11 +30,17 @@ namespace WixToolset.Core.CommandLine | |||
| 30 | this.Platform = platform; | 30 | this.Platform = platform; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | public bool ShowHelp { get; set; } | ||
| 34 | |||
| 35 | public bool ShowLogo { get; set; } | ||
| 36 | |||
| 37 | public bool StopParsing { get; } | ||
| 38 | |||
| 33 | private IServiceProvider ServiceProvider { get; } | 39 | private IServiceProvider ServiceProvider { get; } |
| 34 | 40 | ||
| 35 | public IMessaging Messaging { get; } | 41 | private IMessaging Messaging { get; } |
| 36 | 42 | ||
| 37 | public IExtensionManager ExtensionManager { get; } | 43 | private IExtensionManager ExtensionManager { get; } |
| 38 | 44 | ||
| 39 | private IEnumerable<SourceFile> SourceFiles { get; } | 45 | private IEnumerable<SourceFile> SourceFiles { get; } |
| 40 | 46 | ||
| @@ -44,11 +50,10 @@ namespace WixToolset.Core.CommandLine | |||
| 44 | 50 | ||
| 45 | public IReadOnlyCollection<string> IncludeSearchPaths { get; } | 51 | public IReadOnlyCollection<string> IncludeSearchPaths { get; } |
| 46 | 52 | ||
| 47 | public bool ShowLogo => throw new NotImplementedException(); | 53 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) |
| 48 | 54 | { | |
| 49 | public bool StopParsing => throw new NotImplementedException(); | 55 | throw new NotImplementedException(); |
| 50 | 56 | } | |
| 51 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) => throw new NotImplementedException(); | ||
| 52 | 57 | ||
| 53 | public Task<int> ExecuteAsync(CancellationToken _) | 58 | public Task<int> ExecuteAsync(CancellationToken _) |
| 54 | { | 59 | { |
diff --git a/src/wix/WixToolset.Core/CommandLine/DecompileCommand.cs b/src/wix/WixToolset.Core/CommandLine/DecompileCommand.cs index fc0ab0c9..22853f86 100644 --- a/src/wix/WixToolset.Core/CommandLine/DecompileCommand.cs +++ b/src/wix/WixToolset.Core/CommandLine/DecompileCommand.cs | |||
| @@ -23,8 +23,19 @@ namespace WixToolset.Core.CommandLine | |||
| 23 | this.commandLine = new CommandLine(this.Messaging); | 23 | this.commandLine = new CommandLine(this.Messaging); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | public bool ShowLogo => this.commandLine.ShowLogo; | 26 | public bool ShowHelp |
| 27 | { | ||
| 28 | get { return this.commandLine.ShowHelp; } | ||
| 29 | set { this.commandLine.ShowHelp = value; } | ||
| 30 | } | ||
| 31 | |||
| 32 | public bool ShowLogo | ||
| 33 | { | ||
| 34 | get { return this.commandLine.ShowLogo; } | ||
| 35 | set { this.commandLine.ShowLogo = value; } | ||
| 36 | } | ||
| 27 | 37 | ||
| 38 | // Stop parsing when we've decided to show help. | ||
| 28 | public bool StopParsing => this.commandLine.ShowHelp; | 39 | public bool StopParsing => this.commandLine.ShowHelp; |
| 29 | 40 | ||
| 30 | private IServiceProvider ServiceProvider { get; } | 41 | private IServiceProvider ServiceProvider { get; } |
| @@ -90,9 +101,9 @@ namespace WixToolset.Core.CommandLine | |||
| 90 | 101 | ||
| 91 | public Platform Platform { get; private set; } | 102 | public Platform Platform { get; private set; } |
| 92 | 103 | ||
| 93 | public bool ShowLogo { get; private set; } | 104 | public bool ShowLogo { get; set; } |
| 94 | 105 | ||
| 95 | public bool ShowHelp { get; private set; } | 106 | public bool ShowHelp { get; set; } |
| 96 | 107 | ||
| 97 | public string IntermediateFolder { get; private set; } | 108 | public string IntermediateFolder { get; private set; } |
| 98 | 109 | ||
| @@ -105,12 +116,6 @@ namespace WixToolset.Core.CommandLine | |||
| 105 | var parameter = arg.Substring(1); | 116 | var parameter = arg.Substring(1); |
| 106 | switch (parameter.ToLowerInvariant()) | 117 | switch (parameter.ToLowerInvariant()) |
| 107 | { | 118 | { |
| 108 | case "?": | ||
| 109 | case "h": | ||
| 110 | case "help": | ||
| 111 | this.ShowHelp = true; | ||
| 112 | return true; | ||
| 113 | |||
| 114 | case "intermediatefolder": | 119 | case "intermediatefolder": |
| 115 | this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); | 120 | this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); |
| 116 | return true; | 121 | return true; |
| @@ -119,31 +124,6 @@ namespace WixToolset.Core.CommandLine | |||
| 119 | case "out": | 124 | case "out": |
| 120 | this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); | 125 | this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); |
| 121 | return true; | 126 | return true; |
| 122 | |||
| 123 | case "nologo": | ||
| 124 | this.ShowLogo = false; | ||
| 125 | return true; | ||
| 126 | |||
| 127 | case "v": | ||
| 128 | case "verbose": | ||
| 129 | this.Messaging.ShowVerboseMessages = true; | ||
| 130 | return true; | ||
| 131 | } | ||
| 132 | |||
| 133 | if (parameter.StartsWith("sw")) | ||
| 134 | { | ||
| 135 | this.ParseSuppressWarning(parameter, "sw".Length, parser); | ||
| 136 | return true; | ||
| 137 | } | ||
| 138 | else if (parameter.StartsWith("suppresswarning")) | ||
| 139 | { | ||
| 140 | this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); | ||
| 141 | return true; | ||
| 142 | } | ||
| 143 | else if (parameter.StartsWith("wx")) | ||
| 144 | { | ||
| 145 | this.ParseWarningAsError(parameter, "wx".Length, parser); | ||
| 146 | return true; | ||
| 147 | } | 127 | } |
| 148 | } | 128 | } |
| 149 | else | 129 | else |
| @@ -217,40 +197,6 @@ namespace WixToolset.Core.CommandLine | |||
| 217 | { | 197 | { |
| 218 | return String.IsNullOrEmpty(this.OutputFile) ? Path.ChangeExtension(this.DecompileFilePath, ".wxs") : this.OutputFile; | 198 | return String.IsNullOrEmpty(this.OutputFile) ? Path.ChangeExtension(this.DecompileFilePath, ".wxs") : this.OutputFile; |
| 219 | } | 199 | } |
| 220 | |||
| 221 | private void ParseSuppressWarning(string parameter, int offset, ICommandLineParser parser) | ||
| 222 | { | ||
| 223 | var paramArg = parameter.Substring(offset); | ||
| 224 | if (paramArg.Length == 0) | ||
| 225 | { | ||
| 226 | this.Messaging.SuppressAllWarnings = true; | ||
| 227 | } | ||
| 228 | else if (Int32.TryParse(paramArg, out var suppressWarning) && suppressWarning > 0) | ||
| 229 | { | ||
| 230 | this.Messaging.SuppressWarningMessage(suppressWarning); | ||
| 231 | } | ||
| 232 | else | ||
| 233 | { | ||
| 234 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalSuppressWarningId(paramArg)); | ||
| 235 | } | ||
| 236 | } | ||
| 237 | |||
| 238 | private void ParseWarningAsError(string parameter, int offset, ICommandLineParser parser) | ||
| 239 | { | ||
| 240 | var paramArg = parameter.Substring(offset); | ||
| 241 | if (paramArg.Length == 0) | ||
| 242 | { | ||
| 243 | this.Messaging.WarningsAsError = true; | ||
| 244 | } | ||
| 245 | else if (Int32.TryParse(paramArg, out var elevateWarning) && elevateWarning > 0) | ||
| 246 | { | ||
| 247 | this.Messaging.ElevateWarningMessage(elevateWarning); | ||
| 248 | } | ||
| 249 | else | ||
| 250 | { | ||
| 251 | parser.ReportErrorArgument(parameter, ErrorMessages.IllegalWarningIdAsError(paramArg)); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | } | 200 | } |
| 255 | } | 201 | } |
| 256 | } | 202 | } |
diff --git a/src/wix/WixToolset.Core/CommandLine/HelpCommand.cs b/src/wix/WixToolset.Core/CommandLine/HelpCommand.cs index 4d192d43..9a879cc8 100644 --- a/src/wix/WixToolset.Core/CommandLine/HelpCommand.cs +++ b/src/wix/WixToolset.Core/CommandLine/HelpCommand.cs | |||
| @@ -25,7 +25,17 @@ namespace WixToolset.Core.CommandLine | |||
| 25 | this.Branding = branding; | 25 | this.Branding = branding; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | public bool ShowLogo => true; | 28 | public bool ShowHelp |
| 29 | { | ||
| 30 | get => true; | ||
| 31 | set { } | ||
| 32 | } | ||
| 33 | |||
| 34 | public bool ShowLogo | ||
| 35 | { | ||
| 36 | get => true; | ||
| 37 | set { } | ||
| 38 | } | ||
| 29 | 39 | ||
| 30 | public bool StopParsing => true; | 40 | public bool StopParsing => true; |
| 31 | 41 | ||
| @@ -61,6 +71,9 @@ namespace WixToolset.Core.CommandLine | |||
| 61 | return Task.FromResult(-1); | 71 | return Task.FromResult(-1); |
| 62 | } | 72 | } |
| 63 | 73 | ||
| 64 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) => true; // eat any arguments | 74 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) |
| 75 | { | ||
| 76 | return true; // eat any arguments | ||
| 77 | } | ||
| 65 | } | 78 | } |
| 66 | } | 79 | } |
diff --git a/src/wix/WixToolset.Core/CommandLine/VersionCommand.cs b/src/wix/WixToolset.Core/CommandLine/VersionCommand.cs index b9dacd3a..7e08b66e 100644 --- a/src/wix/WixToolset.Core/CommandLine/VersionCommand.cs +++ b/src/wix/WixToolset.Core/CommandLine/VersionCommand.cs | |||
| @@ -10,7 +10,9 @@ namespace WixToolset.Core.CommandLine | |||
| 10 | 10 | ||
| 11 | internal class VersionCommand : ICommandLineCommand | 11 | internal class VersionCommand : ICommandLineCommand |
| 12 | { | 12 | { |
| 13 | public bool ShowLogo => true; | 13 | public bool ShowHelp { get; set; } |
| 14 | |||
| 15 | public bool ShowLogo { get; set; } | ||
| 14 | 16 | ||
| 15 | public bool StopParsing => true; | 17 | public bool StopParsing => true; |
| 16 | 18 | ||
| @@ -25,6 +27,9 @@ namespace WixToolset.Core.CommandLine | |||
| 25 | return Task.FromResult(0); | 27 | return Task.FromResult(0); |
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) => true; // eat any arguments | 30 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) |
| 31 | { | ||
| 32 | return true; // eat any arguments | ||
| 33 | } | ||
| 29 | } | 34 | } |
| 30 | } | 35 | } |
diff --git a/src/wix/heat/HeatCommand.cs b/src/wix/heat/HeatCommand.cs index 99f27521..56277004 100644 --- a/src/wix/heat/HeatCommand.cs +++ b/src/wix/heat/HeatCommand.cs | |||
| @@ -28,6 +28,12 @@ namespace WixToolset.Harvesters | |||
| 28 | this.ExtensionOptions.Add(harvestType); | 28 | this.ExtensionOptions.Add(harvestType); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | public bool ShowHelp { get; set; } | ||
| 32 | |||
| 33 | public bool ShowLogo { get; set; } | ||
| 34 | |||
| 35 | public bool StopParsing { get; private set; } | ||
| 36 | |||
| 31 | private string ExtensionArgument { get; set; } | 37 | private string ExtensionArgument { get; set; } |
| 32 | 38 | ||
| 33 | private List<string> ExtensionOptions { get; } = new List<string>(); | 39 | private List<string> ExtensionOptions { get; } = new List<string>(); |
| @@ -44,10 +50,6 @@ namespace WixToolset.Harvesters | |||
| 44 | 50 | ||
| 45 | private IServiceProvider ServiceProvider { get; } | 51 | private IServiceProvider ServiceProvider { get; } |
| 46 | 52 | ||
| 47 | public bool ShowLogo { get; private set; } | ||
| 48 | |||
| 49 | public bool StopParsing { get; private set; } | ||
| 50 | |||
| 51 | public Task<int> ExecuteAsync(CancellationToken cancellationToken) | 53 | public Task<int> ExecuteAsync(CancellationToken cancellationToken) |
| 52 | { | 54 | { |
| 53 | var exitCode = this.Harvest(); | 55 | var exitCode = this.Harvest(); |
diff --git a/src/wix/heat/HelpCommand.cs b/src/wix/heat/HelpCommand.cs index bd2bcc24..d991b4fa 100644 --- a/src/wix/heat/HelpCommand.cs +++ b/src/wix/heat/HelpCommand.cs | |||
| @@ -24,7 +24,13 @@ namespace WixToolset.Harvesters | |||
| 24 | 24 | ||
| 25 | private IList<IHeatExtension> Extensions { get; } | 25 | private IList<IHeatExtension> Extensions { get; } |
| 26 | 26 | ||
| 27 | public bool ShowLogo => false; | 27 | public bool ShowHelp { get; set; } |
| 28 | |||
| 29 | public bool ShowLogo | ||
| 30 | { | ||
| 31 | get => false; | ||
| 32 | set { } | ||
| 33 | } | ||
| 28 | 34 | ||
| 29 | public bool StopParsing => true; | 35 | public bool StopParsing => true; |
| 30 | 36 | ||
| @@ -39,12 +45,15 @@ namespace WixToolset.Harvesters | |||
| 39 | var wixcopAssembly = typeof(HelpCommand).Assembly; | 45 | var wixcopAssembly = typeof(HelpCommand).Assembly; |
| 40 | var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location); | 46 | var fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location); |
| 41 | 47 | ||
| 42 | Console.WriteLine("WiX Toolset Harvester version {0}", fv.FileVersion); | 48 | Console.WriteLine("WiX Toolset Harvester version {0}", fv.ProductVersion); |
| 43 | Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved."); | 49 | Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved."); |
| 44 | Console.WriteLine(); | 50 | Console.WriteLine(); |
| 45 | } | 51 | } |
| 46 | 52 | ||
| 47 | public bool TryParseArgument(ICommandLineParser parser, string argument) => true; | 53 | public bool TryParseArgument(ICommandLineParser parser, string argument) |
| 54 | { | ||
| 55 | return true; | ||
| 56 | } | ||
| 48 | 57 | ||
| 49 | private int DisplayHelp() | 58 | private int DisplayHelp() |
| 50 | { | 59 | { |
