main
cs 51 lines 1.82 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 WixToolset.Extensibility;
7 using WixToolset.Extensibility.Data;
8 using WixToolset.Extensibility.Services;
9
10 /// <summary>
11 /// Parses the "convert" command-line command. See <c>ConvertCommand</c> for
12 /// the bulk of the command-line processing.
13 /// </summary>
14 internal class ConverterExtensionCommandLine : BaseExtensionCommandLine
15 {
16 public ConverterExtensionCommandLine(IServiceProvider serviceProvider)
17 {
18 this.ServiceProvider = serviceProvider;
19 }
20
21 private IServiceProvider ServiceProvider { get; }
22
23 public override CommandLineHelp GetCommandLineHelp()
24 {
25 return new CommandLineHelp("Source code converter and formatter.")
26 {
27 Commands = new[]
28 {
29 new CommandLineHelpCommand("convert", "Convert v3 source code to v4 source code."),
30 new CommandLineHelpCommand("format", "Ensure consistent formatting of source code."),
31 }
32 };
33 }
34
35 public override bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command)
36 {
37 command = null;
38
39 if ("convert".Equals(argument, StringComparison.OrdinalIgnoreCase))
40 {
41 command = new ConvertCommand(this.ServiceProvider);
42 }
43 else if ("format".Equals(argument, StringComparison.OrdinalIgnoreCase))
44 {
45 command = new FormatCommand(this.ServiceProvider);
46 }
47
48 return command != null;
49 }
50 }
51 }