Skip to content

Commit ee2f58e

Browse files
committed
Rename parser mode enums as per discussion
After discussion in PR commandlineparser#684, renamed ParserMode enums to GetoptParserV1 and GetoptParserV2, so as to not communicate the idea that the older mode is in any way obsolete (it will continue to be supported for the foreseeable future).
1 parent e9dc2f1 commit ee2f58e

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/CommandLine/Parser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ private static Result<IEnumerable<Token>, Error> Tokenize(
187187
{
188188
switch (settings.ParserMode)
189189
{
190-
case ParserMode.Classic:
190+
case ParserMode.GetoptParserV1:
191191
return Tokenizer.ConfigureTokenizer(
192192
settings.NameComparer,
193193
settings.IgnoreUnknownArguments,
194194
settings.EnableDashDash)(arguments, optionSpecs);
195195

196-
case ParserMode.Getopt:
196+
case ParserMode.GetoptParserV2:
197197
return GetoptTokenizer.ConfigureTokenizer(
198198
settings.NameComparer,
199199
settings.IgnoreUnknownArguments,

src/CommandLine/ParserSettings.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace CommandLine
1111
{
1212
public enum ParserMode
1313
{
14-
Classic,
15-
Getopt,
14+
GetoptParserV1,
15+
GetoptParserV2,
1616

17-
Default = Classic
17+
Default = GetoptParserV1
1818
}
1919

2020
/// <summary>
@@ -174,11 +174,11 @@ public bool AutoVersion
174174
/// <summary>
175175
/// Gets or sets a value indicating whether enable double dash '--' syntax,
176176
/// that forces parsing of all subsequent tokens as values.
177-
/// Normally defaults to false. If ParserMode = ParserMode.Getopt, this defaults to true, but can be turned off by explicitly specifying EnableDashDash = false.
177+
/// Normally defaults to false. If ParserMode = ParserMode.GetoptParserV2, this defaults to true, but can be turned off by explicitly specifying EnableDashDash = false.
178178
/// </summary>
179179
public bool EnableDashDash
180180
{
181-
get => enableDashDash.MatchJust(out bool value) ? value : (parserMode == ParserMode.Getopt);
181+
get => enableDashDash.MatchJust(out bool value) ? value : (parserMode == ParserMode.GetoptParserV2);
182182
set => PopsicleSetter.Set(Consumed, ref enableDashDash, Maybe.Just(value));
183183
}
184184

@@ -193,11 +193,11 @@ public int MaximumDisplayWidth
193193

194194
/// <summary>
195195
/// Gets or sets a value indicating whether options are allowed to be specified multiple times.
196-
/// If ParserMode = ParserMode.Getopt, this defaults to true, but can be turned off by explicitly specifying AllowMultiInstance = false.
196+
/// If ParserMode = ParserMode.GetoptParserV2, this defaults to true, but can be turned off by explicitly specifying AllowMultiInstance = false.
197197
/// </summary>
198198
public bool AllowMultiInstance
199199
{
200-
get => allowMultiInstance.MatchJust(out bool value) ? value : (parserMode == ParserMode.Getopt);
200+
get => allowMultiInstance.MatchJust(out bool value) ? value : (parserMode == ParserMode.GetoptParserV2);
201201
set => PopsicleSetter.Set(Consumed, ref allowMultiInstance, Maybe.Just(value));
202202
}
203203

tests/CommandLine.Tests/Unit/GetoptParserTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void Getopt_parser_without_posixly_correct_allows_mixed_options_and_nonop
155155
{
156156
// Arrange
157157
var sut = new Parser(config => {
158-
config.ParserMode = ParserMode.Getopt;
158+
config.ParserMode = ParserMode.GetoptParserV2;
159159
config.PosixlyCorrect = false;
160160
});
161161

@@ -215,7 +215,7 @@ public void Getopt_parser_with_posixly_correct_stops_parsing_at_first_nonoption(
215215
{
216216
// Arrange
217217
var sut = new Parser(config => {
218-
config.ParserMode = ParserMode.Getopt;
218+
config.ParserMode = ParserMode.GetoptParserV2;
219219
config.PosixlyCorrect = true;
220220
config.EnableDashDash = true;
221221
});
@@ -233,7 +233,7 @@ public void Getopt_mode_defaults_to_EnableDashDash_being_true()
233233
{
234234
// Arrange
235235
var sut = new Parser(config => {
236-
config.ParserMode = ParserMode.Getopt;
236+
config.ParserMode = ParserMode.GetoptParserV2;
237237
config.PosixlyCorrect = false;
238238
});
239239
var args = new string [] {"--stringvalue", "foo", "256", "--", "-x", "-sbar" };
@@ -259,7 +259,7 @@ public void Getopt_mode_can_have_EnableDashDash_expicitly_disabled()
259259
{
260260
// Arrange
261261
var sut = new Parser(config => {
262-
config.ParserMode = ParserMode.Getopt;
262+
config.ParserMode = ParserMode.GetoptParserV2;
263263
config.PosixlyCorrect = false;
264264
config.EnableDashDash = false;
265265
});

tests/CommandLine.Tests/Unit/SequenceParsingTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public class SequenceParsingTests
1717
{
1818
// Issue #91
1919
[Theory]
20-
[InlineData(ParserMode.Classic)]
21-
[InlineData(ParserMode.Getopt)]
20+
[InlineData(ParserMode.GetoptParserV1)]
21+
[InlineData(ParserMode.GetoptParserV2)]
2222
public static void Enumerable_with_separator_before_values_does_not_try_to_parse_too_much(ParserMode parserMode)
2323
{
2424
var args = "--exclude=a,b InputFile.txt".Split();
@@ -35,8 +35,8 @@ public static void Enumerable_with_separator_before_values_does_not_try_to_parse
3535

3636
// Issue #396
3737
[Theory]
38-
[InlineData(ParserMode.Classic)]
39-
[InlineData(ParserMode.Getopt)]
38+
[InlineData(ParserMode.GetoptParserV1)]
39+
[InlineData(ParserMode.GetoptParserV2)]
4040
public static void Options_with_similar_names_are_not_ambiguous(ParserMode parserMode)
4141
{
4242
var args = new[] { "--configure-profile", "deploy", "--profile", "local" };
@@ -68,8 +68,8 @@ public static void Values_with_same_name_as_sequence_option_do_not_cause_later_v
6868

6969
// Issue #454
7070
[Theory]
71-
[InlineData(ParserMode.Classic)]
72-
[InlineData(ParserMode.Getopt)]
71+
[InlineData(ParserMode.GetoptParserV1)]
72+
[InlineData(ParserMode.GetoptParserV2)]
7373

7474
public static void Enumerable_with_colon_separator_before_values_does_not_try_to_parse_too_much(ParserMode parserMode)
7575
{
@@ -86,8 +86,8 @@ public static void Enumerable_with_colon_separator_before_values_does_not_try_to
8686

8787
// Issue #510
8888
[Theory]
89-
[InlineData(ParserMode.Classic)]
90-
[InlineData(ParserMode.Getopt)]
89+
[InlineData(ParserMode.GetoptParserV1)]
90+
[InlineData(ParserMode.GetoptParserV2)]
9191

9292
public static void Enumerable_before_values_does_not_try_to_parse_too_much(ParserMode parserMode)
9393
{
@@ -101,8 +101,8 @@ public static void Enumerable_before_values_does_not_try_to_parse_too_much(Parse
101101

102102
// Issue #617
103103
[Theory]
104-
[InlineData(ParserMode.Classic)]
105-
[InlineData(ParserMode.Getopt)]
104+
[InlineData(ParserMode.GetoptParserV1)]
105+
[InlineData(ParserMode.GetoptParserV2)]
106106

107107
public static void Enumerable_with_enum_before_values_does_not_try_to_parse_too_much(ParserMode parserMode)
108108
{
@@ -119,8 +119,8 @@ public static void Enumerable_with_enum_before_values_does_not_try_to_parse_too_
119119

120120
// Issue #619
121121
[Theory]
122-
[InlineData(ParserMode.Classic)]
123-
[InlineData(ParserMode.Getopt)]
122+
[InlineData(ParserMode.GetoptParserV1)]
123+
[InlineData(ParserMode.GetoptParserV2)]
124124

125125
public static void Separator_just_before_values_does_not_try_to_parse_values(ParserMode parserMode)
126126
{

0 commit comments

Comments
 (0)