aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs')
-rw-r--r--src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs
index 65dde0f4..345e0448 100644
--- a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs
+++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs
@@ -3,6 +3,7 @@
3namespace WixToolset.Mba.Core 3namespace WixToolset.Mba.Core
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic;
6 using System.ComponentModel; 7 using System.ComponentModel;
7 using System.Runtime.InteropServices; 8 using System.Runtime.InteropServices;
8 9
@@ -11,8 +12,6 @@ namespace WixToolset.Mba.Core
11 /// </summary> 12 /// </summary>
12 public sealed class BootstrapperCommand : IBootstrapperCommand 13 public sealed class BootstrapperCommand : IBootstrapperCommand
13 { 14 {
14 private readonly string commandLine;
15
16 /// <summary> 15 /// <summary>
17 /// 16 ///
18 /// </summary> 17 /// </summary>
@@ -45,7 +44,7 @@ namespace WixToolset.Mba.Core
45 this.Action = action; 44 this.Action = action;
46 this.Display = display; 45 this.Display = display;
47 this.Restart = restart; 46 this.Restart = restart;
48 this.commandLine = commandLine; 47 this.CommandLine = commandLine;
49 this.CmdShow = cmdShow; 48 this.CmdShow = cmdShow;
50 this.Resume = resume; 49 this.Resume = resume;
51 this.SplashScreen = splashScreen; 50 this.SplashScreen = splashScreen;
@@ -66,7 +65,7 @@ namespace WixToolset.Mba.Core
66 public Restart Restart { get; } 65 public Restart Restart { get; }
67 66
68 /// <inheritdoc/> 67 /// <inheritdoc/>
69 public string[] CommandLineArgs => GetCommandLineArgs(this.commandLine); 68 public string CommandLine { get; }
70 69
71 /// <inheritdoc/> 70 /// <inheritdoc/>
72 public int CmdShow { get; } 71 public int CmdShow { get; }
@@ -92,6 +91,49 @@ namespace WixToolset.Mba.Core
92 /// <inheritdoc/> 91 /// <inheritdoc/>
93 public string BootstrapperApplicationDataPath { get; } 92 public string BootstrapperApplicationDataPath { get; }
94 93
94 /// <inheritdoc/>
95 public IMbaCommand ParseCommandLine()
96 {
97 var args = ParseCommandLineToArgs(this.CommandLine);
98 var unknownArgs = new List<string>();
99 var variables = new List<KeyValuePair<string, string>>();
100
101 foreach (var arg in args)
102 {
103 var unknownArg = false;
104
105 if (arg[0] == '-' || arg[0] == '/')
106 {
107 unknownArg = true;
108 }
109 else
110 {
111 var index = arg.IndexOf('=');
112 if (index == -1)
113 {
114 unknownArg = true;
115 }
116 else
117 {
118 var name = arg.Substring(0, index);
119 var value = arg.Substring(index + 1);
120 variables.Add(new KeyValuePair<string, string>(name, value));
121 }
122 }
123
124 if (unknownArg)
125 {
126 unknownArgs.Add(arg);
127 }
128 }
129
130 return new MbaCommand
131 {
132 UnknownCommandLineArgs = unknownArgs.ToArray(),
133 Variables = variables.ToArray(),
134 };
135 }
136
95 /// <summary> 137 /// <summary>
96 /// Gets the command line arguments as a string array. 138 /// Gets the command line arguments as a string array.
97 /// </summary> 139 /// </summary>
@@ -102,7 +144,7 @@ namespace WixToolset.Mba.Core
102 /// <remarks> 144 /// <remarks>
103 /// This method uses the same parsing as the operating system which handles quotes and spaces correctly. 145 /// This method uses the same parsing as the operating system which handles quotes and spaces correctly.
104 /// </remarks> 146 /// </remarks>
105 public static string[] GetCommandLineArgs(string commandLine) 147 public static string[] ParseCommandLineToArgs(string commandLine)
106 { 148 {
107 if (null == commandLine) 149 if (null == commandLine)
108 { 150 {