Skip to content

Commit c7c918b

Browse files
committed
started to extend the additional arguments tests
1 parent ffdfc30 commit c7c918b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

FluentCommandLineParser.Tests/Internals/CommandLineParserEngineMark2Tests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,39 @@ class when_args_contains_single_switch : ParseTestContext
121121
It should_set_the_parsed_raw_key_to_the_correct_value = () =>
122122
result.ParsedOptions.First().RawKey.ShouldEqual("-b");
123123
}
124+
125+
class when_args_contains_only_the_double_dash_option_prefix : ParseTestContext
126+
{
127+
Establish context = () => SetupArgs("--");
128+
129+
It should_return_no_parsed_options = () =>
130+
result.ParsedOptions.ShouldBeEmpty();
131+
132+
It should_return_it_as_an_additional = () =>
133+
result.AdditionalValues.ShouldContainOnly("--");
134+
}
135+
136+
class when_args_contains_only_the_single_dash_option_prefix : ParseTestContext
137+
{
138+
Establish context = () => SetupArgs("-");
139+
140+
It should_return_no_parsed_options = () =>
141+
result.ParsedOptions.ShouldBeEmpty();
142+
143+
It should_return_it_as_an_additional = () =>
144+
result.AdditionalValues.ShouldContainOnly("-");
145+
}
146+
147+
class when_args_contains_only_the_slash_option_prefix : ParseTestContext
148+
{
149+
Establish context = () => SetupArgs("/");
150+
151+
It should_return_no_parsed_options = () =>
152+
result.ParsedOptions.ShouldBeEmpty();
153+
154+
It should_return_it_as_an_additional = () =>
155+
result.AdditionalValues.ShouldContainOnly("/");
156+
}
124157
}
125158
}
126159

FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private void ParseGroupIntoOption(string rawKey, IEnumerable<string> optionGroup
6969
}
7070
else
7171
{
72+
_additionalOptionsFound.Add(rawKey);
7273
_additionalOptionsFound.AddRange(optionGroup);
7374
}
7475
}
@@ -122,7 +123,9 @@ private static void TrimSuffix(ParsedOption parsedOption)
122123
/// <returns><c>true</c> if <paramref name="arg"/> is a Option key; otherwise <c>false</c>.</returns>
123124
static bool IsAKey(string arg)
124125
{
125-
return arg != null && SpecialCharacters.OptionPrefix.Any(arg.StartsWith);
126+
return arg != null
127+
&& SpecialCharacters.OptionPrefix.Any(arg.StartsWith)
128+
&& SpecialCharacters.OptionPrefix.Any(arg.Equals) == false;
126129
}
127130

128131
/// <summary>

0 commit comments

Comments
 (0)