aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Converters/ConverterExtensionCommandLine.cs
blob: d78b89cca8c91caefc129cf91e29762a6095ab6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// 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.

namespace WixToolset.Converters
{
    using System;
    using System.Collections.Generic;
    using WixToolset.Extensibility;
    using WixToolset.Extensibility.Data;
    using WixToolset.Extensibility.Services;

    /// <summary>
    /// Parses the "convert" command-line command. See <c>ConvertCommand</c> for
    /// the bulk of the command-line processing.
    /// </summary>
    internal class ConverterExtensionCommandLine : BaseExtensionCommandLine
    {
        public ConverterExtensionCommandLine(IWixToolsetServiceProvider serviceProvider)
        {
            this.ServiceProvider = serviceProvider;
        }

        private IWixToolsetServiceProvider ServiceProvider { get; }

        public override IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches => new ExtensionCommandLineSwitch[]
        {
            new ExtensionCommandLineSwitch { Switch = "convert", Description = "Convert v3 source code to v4 source code." },
            new ExtensionCommandLineSwitch { Switch = "format", Description = "Ensures consistent formatting of source code." },
        };

        public override bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command)
        {
            command = null;

            if ("convert".Equals(argument, StringComparison.OrdinalIgnoreCase))
            {
                command = new ConvertCommand(this.ServiceProvider);
            }
            else if ("format".Equals(argument, StringComparison.OrdinalIgnoreCase))
            {
                command = new FormatCommand(this.ServiceProvider);
            }

            return command != null;
        }
    }
}