Skip to content

Commit 96d1e2d

Browse files
committed
Fixed a bug with the argument regular expressions which would parse operands containing a dash into two operands. Added a test.
1 parent 2886f18 commit 96d1e2d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Utility.CommandLine.Arguments.Tests/Arguments.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ public void ParseOperands()
309309
Assert.Equal("four", test.OperandList[2]);
310310
}
311311

312+
/// <summary>
313+
/// Tests the <see cref="Utility.CommandLine.Arguments.Parse(string)"/> method with a string coning a single operand
314+
/// which contains a dash.
315+
/// </summary>
316+
[Fact]
317+
public void ParseDashedOperand()
318+
{
319+
CommandLine.Arguments test = CommandLine.Arguments.Parse("hello-world");
320+
321+
Assert.Equal("hello-world", test.OperandList[0]);
322+
}
323+
312324
/// <summary>
313325
/// Tests the <see cref="Utility.CommandLine.Arguments.Parse(string)"/> method with an explicit command line string
314326
/// containing only short parameters.

Utility.CommandLine.Arguments/Arguments.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public class Arguments
130130
/// <summary>
131131
/// The regular expression with which to parse the command line string.
132132
/// </summary>
133-
private const string ArgumentRegEx = "(?:[-]{1,2}|\\/)([\\w-]+)[=|:| ]?(\\w\\S*|\\\"[^\"]*\\\"|\\\'[^']*\\\')?|([^- ([^'\\\"]+|\"[^\\\"]+\"|\\\'[^']+\\\')";
133+
private const string ArgumentRegEx = "(?:[-]{1,2}|\\/)([\\w-]+)[=|:| ]?(\\w\\S*|\\\"[^\"]*\\\"|\\\'[^']*\\\')?|([^ ([^'\\\"]+|\"[^\\\"]+\"|\\\'[^']+\\\')";
134134

135135
/// <summary>
136136
/// The regular expression with which to parse argument-value groups.

0 commit comments

Comments
 (0)