Skip to content

Commit 9bb9d30

Browse files
committed
add EnableForwardSlash prop, tweak regex with and without
1 parent 750a47b commit 9bb9d30

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Utility.CommandLine.Arguments/Arguments.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ public class Arguments
176176
/// <summary>
177177
/// The regular expression with which to parse the command line string.
178178
/// </summary>
179-
private const string ArgumentRegEx = "(?:[-]{1,2}|\\/)([^=: ]+)[=: ]?([^-'\"\\/]\\S*|\\\"[^\"]*\\\"|\\\'[^']*\\\')?|([^ ([^'\\\"]+|\"[^\\\"]+\"|\\\'[^']+\\\')";
179+
private const string ArgumentRegExWithoutForwardSlash = "(?:[-]{1,2})([^=: ]+)[=: ]?([^-'\"]\\S*|\\\"[^\"]*\\\"|\\\'[^']*\\\')?|([^ ([^'\\\"]+|\"[^\\\"]+\"|\\\'[^']+\\\')";
180+
181+
/// <summary>
182+
/// The regular expression with which to parse the command line string, including the ability to specify forward slashes.
183+
/// </summary>
184+
private const string ArgumentRegExWithForwardSlash = "(?:[-]{1,2}|\\/)([^=: ]+)[=: ]?([^-'\"\\/]\\S*|\\\"[^\"]*\\\"|\\\'[^']*\\\')?|([^ ([^'\\\"]+|\"[^\\\"]+\"|\\\'[^']+\\\')";
180185

181186
/// <summary>
182187
/// The regular expression with which to parse argument-value groups.
@@ -207,6 +212,11 @@ private Arguments(string commandLineString, List<KeyValuePair<string, string>> a
207212
TargetType = targetType;
208213
}
209214

215+
/// <summary>
216+
/// Gets or sets a value indicating whether forward slashes are processed as argument delimiters.
217+
/// </summary>
218+
public static bool EnableForwardSlash { get; set; } = false;
219+
210220
/// <summary>
211221
/// Gets a dictionary containing the arguments and values specified in the command line arguments with which the
212222
/// application was started.
@@ -242,6 +252,8 @@ private Arguments(string commandLineString, List<KeyValuePair<string, string>> a
242252
/// </summary>
243253
public Type TargetType { get; }
244254

255+
private static string ArgumentRegEx => EnableForwardSlash ? ArgumentRegExWithForwardSlash : ArgumentRegExWithoutForwardSlash;
256+
245257
/// <summary>
246258
/// Gets the argument value corresponding to the specified <paramref name="index"/>.
247259
/// </summary>

0 commit comments

Comments
 (0)