diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine/CommandLineParser.cs')
-rw-r--r-- | src/WixToolset.Core/CommandLine/CommandLineParser.cs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs index 65aea1fc..92944ab2 100644 --- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs +++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs | |||
@@ -7,6 +7,7 @@ namespace WixToolset.Core.CommandLine | |||
7 | using System.IO; | 7 | using System.IO; |
8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
10 | using WixToolset.Extensibility.Data; | ||
10 | using WixToolset.Extensibility.Services; | 11 | using WixToolset.Extensibility.Services; |
11 | 12 | ||
12 | internal enum Commands | 13 | internal enum Commands |
@@ -19,27 +20,34 @@ namespace WixToolset.Core.CommandLine | |||
19 | Bind, | 20 | Bind, |
20 | } | 21 | } |
21 | 22 | ||
22 | internal class CommandLineParser : ICommandLine | 23 | internal class CommandLineParser : ICommandLineParser |
23 | { | 24 | { |
24 | private IServiceProvider ServiceProvider { get; set; } | 25 | public CommandLineParser(IServiceProvider serviceProvider) |
26 | { | ||
27 | this.ServiceProvider = serviceProvider; | ||
28 | |||
29 | this.Messaging = this.ServiceProvider.GetService<IMessaging>(); | ||
30 | } | ||
31 | |||
32 | private IServiceProvider ServiceProvider { get; } | ||
25 | 33 | ||
26 | private IMessaging Messaging { get; set; } | 34 | private IMessaging Messaging { get; set; } |
27 | 35 | ||
36 | public IExtensionManager ExtensionManager { get; set; } | ||
37 | |||
38 | public ICommandLineArguments Arguments { get; set; } | ||
39 | |||
28 | public static string ExpectedArgument { get; } = "expected argument"; | 40 | public static string ExpectedArgument { get; } = "expected argument"; |
29 | 41 | ||
30 | public string ActiveCommand { get; private set; } | 42 | public string ActiveCommand { get; private set; } |
31 | 43 | ||
32 | public IExtensionManager ExtensionManager { get; private set; } | 44 | public bool ShowHelp { get; private set; } |
33 | |||
34 | public bool ShowHelp { get; set; } | ||
35 | 45 | ||
36 | public ICommandLineCommand ParseStandardCommandLine(ICommandLineContext context) | 46 | public ICommandLineCommand ParseStandardCommandLine() |
37 | { | 47 | { |
38 | this.ServiceProvider = context.ServiceProvider; | 48 | var context = this.ServiceProvider.GetService<ICommandLineContext>(); |
39 | 49 | context.ExtensionManager = this.ExtensionManager ?? this.ServiceProvider.GetService<IExtensionManager>(); | |
40 | this.Messaging = context.Messaging ?? this.ServiceProvider.GetService<IMessaging>(); | 50 | context.Arguments = this.Arguments; |
41 | |||
42 | this.ExtensionManager = context.ExtensionManager ?? this.ServiceProvider.GetService<IExtensionManager>(); | ||
43 | 51 | ||
44 | var next = String.Empty; | 52 | var next = String.Empty; |
45 | 53 | ||
@@ -277,7 +285,7 @@ namespace WixToolset.Core.CommandLine | |||
277 | return OutputType.Unknown; | 285 | return OutputType.Unknown; |
278 | } | 286 | } |
279 | 287 | ||
280 | private ICommandLine Parse(ICommandLineContext context, Func<CommandLineParser, string, bool> parseCommand, Func<CommandLineParser, IParseCommandLine, string, bool> parseArgument) | 288 | private ICommandLineParser Parse(ICommandLineContext context, Func<CommandLineParser, string, bool> parseCommand, Func<CommandLineParser, IParseCommandLine, string, bool> parseArgument) |
281 | { | 289 | { |
282 | var extensions = this.ExtensionManager.Create<IExtensionCommandLine>(); | 290 | var extensions = this.ExtensionManager.Create<IExtensionCommandLine>(); |
283 | 291 | ||