main
cs 51 lines 2.17 KB
Raw
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.Converters
4 {
5 using System;
6 using System.Threading;
7 using System.Threading.Tasks;
8 using WixToolset.Extensibility.Data;
9
10 internal class ConvertCommand : FixupCommandBase
11 {
12 private const string SettingsFileDefault = "wix.convert.settings.xml";
13
14 public ConvertCommand(IServiceProvider serviceProvider) : base(serviceProvider)
15 {
16 }
17
18 public override CommandLineHelp GetCommandLineHelp()
19 {
20 return new CommandLineHelp("Convert v3 source code to v4 source code.", "convert [options] sourceFile [sourceFile ...]")
21 {
22 Switches = new[]
23 {
24 new CommandLineHelpSwitch("--custom-table", "Convert custom table authoring for use in MSI packages (msi) or bundles (bundle)."),
25 new CommandLineHelpSwitch("--dry-run", "-n", "Only display errors, do not update files."),
26 new CommandLineHelpSwitch("--recurse", "-r", "Search for matching files in current dir and subdirs."),
27 new CommandLineHelpSwitch("-set1<file>", "Primary settings file."),
28 new CommandLineHelpSwitch("-set2<file>", "Secondary settings file (overrides primary)."),
29 new CommandLineHelpSwitch("-indent:<n>", "Indentation multiple (overrides default of 4)."),
30 },
31 Notes = " sourceFile may use wildcards like *.wxs"
32 };
33 }
34
35 public override Task<int> ExecuteAsync(CancellationToken cancellationToken)
36 {
37 this.ParseSettings(SettingsFileDefault);
38
39 var converter = new WixConverter(this.Messaging, this.IndentationAmount, this.ErrorsAsWarnings, this.IgnoreErrors);
40
41 var errors = base.Inspect(Inspector, cancellationToken);
42
43 return Task.FromResult(errors);
44
45 int Inspector(string file, bool fix)
46 {
47 return converter.ConvertFile(file, fix);
48 }
49 }
50 }
51 }