diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine/CommandLineParser.cs')
-rw-r--r-- | src/WixToolset.Core/CommandLine/CommandLineParser.cs | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs index 11e5751d..2ee1e9ae 100644 --- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs +++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs | |||
@@ -27,7 +27,7 @@ namespace WixToolset.Core.CommandLine | |||
27 | 27 | ||
28 | public bool IsSwitch(string arg) | 28 | public bool IsSwitch(string arg) |
29 | { | 29 | { |
30 | return !String.IsNullOrEmpty(arg) && ('/' == arg[0] || '-' == arg[0]); | 30 | return !String.IsNullOrEmpty(arg) && '-' == arg[0]; |
31 | } | 31 | } |
32 | 32 | ||
33 | public string GetArgumentAsFilePathOrError(string argument, string fileType) | 33 | public string GetArgumentAsFilePathOrError(string argument, string fileType) |
@@ -74,7 +74,7 @@ namespace WixToolset.Core.CommandLine | |||
74 | 74 | ||
75 | public string GetNextArgumentAsDirectoryOrError(string commandLineSwitch) | 75 | public string GetNextArgumentAsDirectoryOrError(string commandLineSwitch) |
76 | { | 76 | { |
77 | if (this.TryGetNextNonSwitchArgumentOrError(out var arg) && this.TryGetDirectory(commandLineSwitch, this.Messaging, arg, out var directory)) | 77 | if (this.TryGetNextNonSwitchArgumentOrError(out var arg) && this.TryGetDirectory(commandLineSwitch, arg, out var directory)) |
78 | { | 78 | { |
79 | return directory; | 79 | return directory; |
80 | } | 80 | } |
@@ -85,7 +85,7 @@ namespace WixToolset.Core.CommandLine | |||
85 | 85 | ||
86 | public bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList<string> directories) | 86 | public bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList<string> directories) |
87 | { | 87 | { |
88 | if (this.TryGetNextNonSwitchArgumentOrError(out var arg) && this.TryGetDirectory(commandLineSwitch, this.Messaging, arg, out var directory)) | 88 | if (this.TryGetNextNonSwitchArgumentOrError(out var arg) && this.TryGetDirectory(commandLineSwitch, arg, out var directory)) |
89 | { | 89 | { |
90 | directories.Add(directory); | 90 | directories.Add(directory); |
91 | return true; | 91 | return true; |
@@ -124,7 +124,14 @@ namespace WixToolset.Core.CommandLine | |||
124 | 124 | ||
125 | public bool TryGetNextSwitchOrArgument(out string arg) | 125 | public bool TryGetNextSwitchOrArgument(out string arg) |
126 | { | 126 | { |
127 | return TryDequeue(this.RemainingArguments, out arg); | 127 | if (this.RemainingArguments.Count > 0) |
128 | { | ||
129 | arg = this.RemainingArguments.Dequeue(); | ||
130 | return true; | ||
131 | } | ||
132 | |||
133 | arg = null; | ||
134 | return false; | ||
128 | } | 135 | } |
129 | 136 | ||
130 | private bool TryGetNextNonSwitchArgumentOrError(out string arg) | 137 | private bool TryGetNextNonSwitchArgumentOrError(out string arg) |
@@ -139,24 +146,7 @@ namespace WixToolset.Core.CommandLine | |||
139 | return result; | 146 | return result; |
140 | } | 147 | } |
141 | 148 | ||
142 | private static bool IsValidArg(string arg) | 149 | private bool TryGetDirectory(string commandlineSwitch, string arg, out string directory) |
143 | { | ||
144 | return !(String.IsNullOrEmpty(arg) || '/' == arg[0] || '-' == arg[0]); | ||
145 | } | ||
146 | |||
147 | private static bool TryDequeue(Queue<string> q, out string arg) | ||
148 | { | ||
149 | if (q.Count > 0) | ||
150 | { | ||
151 | arg = q.Dequeue(); | ||
152 | return true; | ||
153 | } | ||
154 | |||
155 | arg = null; | ||
156 | return false; | ||
157 | } | ||
158 | |||
159 | private bool TryGetDirectory(string commandlineSwitch, IMessaging messageHandler, string arg, out string directory) | ||
160 | { | 150 | { |
161 | directory = null; | 151 | directory = null; |
162 | 152 | ||
@@ -174,7 +164,7 @@ namespace WixToolset.Core.CommandLine | |||
174 | { | 164 | { |
175 | path = null; | 165 | path = null; |
176 | 166 | ||
177 | if (!IsValidArg(arg)) | 167 | if (String.IsNullOrEmpty(arg) || '-' == arg[0]) |
178 | { | 168 | { |
179 | this.Messaging.Write(ErrorMessages.FilePathRequired(commandlineSwitch)); | 169 | this.Messaging.Write(ErrorMessages.FilePathRequired(commandlineSwitch)); |
180 | } | 170 | } |