Skip to content

Commit 9cdcb23

Browse files
authored
rename Option.Required to Option.IsRequired (#967)
1 parent 809ba57 commit 9cdcb23

File tree

10 files changed

+14
-15
lines changed

10 files changed

+14
-15
lines changed

samples/HostingPlayground/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private static CommandLineBuilder BuildCommandLine()
3030
{
3131
var root = new RootCommand(@"$ dotnet run --name 'Joe'"){
3232
new Option<string>("--name"){
33-
Required = true
33+
IsRequired = true
3434
}
3535
};
3636
root.Handler = CommandHandler.Create<GreeterOptions, IHost>(Run);

src/System.CommandLine.Tests/ApprovalTests/Help/HelpBuilderTests.Approval.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
3434
},
3535
new Option(aliases: new string[] {"--the-root-option-no-arg", "-trna"}) {
3636
Description = "the-root-option-no-arg-description",
37-
Required = true
37+
IsRequired = true
3838
},
3939
new Option<string>(
4040
aliases: new string[] {"--the-root-option-no-description-default-arg", "-trondda"},
@@ -47,7 +47,7 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
4747
{
4848
Description = "the-root-option-arg-no-default-description"
4949
},
50-
Required = true
50+
IsRequired = true
5151
},
5252
new Option(aliases: new string[] {"--the-root-option-default-arg", "-troda"}) {
5353
Description = "the-root-option-default-arg-description",
@@ -69,7 +69,7 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
6969
{
7070
Description = "the-root-option-arg-description",
7171
},
72-
Required = true
72+
IsRequired = true
7373
}
7474
};
7575
command.Name = "the-root-command";

src/System.CommandLine.Tests/Help/HelpBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ public void Required_options_are_indicated()
11721172
{
11731173
new Option("--required")
11741174
{
1175-
Required = true
1175+
IsRequired = true
11761176
}
11771177
};
11781178

@@ -1191,7 +1191,7 @@ public void Required_options_are_indicated_when_argument_is_named()
11911191
{
11921192
new Option(new[] {"-r", "--required" })
11931193
{
1194-
Required = true,
1194+
IsRequired = true,
11951195
Argument = new Argument<string>("ARG")
11961196
}
11971197
};

src/System.CommandLine.Tests/ParsingValidationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void When_a_required_option_is_not_supplied_then_an_error_is_returned()
9090
{
9191
new Option("-x")
9292
{
93-
Required = true
93+
IsRequired = true
9494
}
9595
};
9696

@@ -112,7 +112,7 @@ public void When_a_required_option_is_allowed_at_more_than_one_position_it_only_
112112
{
113113
var option = new Option<string>("-x")
114114
{
115-
Required = true
115+
IsRequired = true
116116
};
117117

118118
var command = new RootCommand
@@ -136,7 +136,7 @@ public void Required_options_on_parent_commands_do_not_create_parse_errors_when_
136136

137137
var parent = new RootCommand
138138
{
139-
new Option<string>("-x") { Required = true },
139+
new Option<string>("-x") { IsRequired = true },
140140
child
141141
};
142142
parent.Name = "parent";

src/System.CommandLine.Tests/SuggestionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Collections.Generic;
55
using System.CommandLine.Builder;
6-
using System.CommandLine.Invocation;
76
using System.CommandLine.Parsing;
87
using System.CommandLine.Tests.Utility;
98
using System.IO;

src/System.CommandLine.Tests/UseHelpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void There_are_no_parse_errors_when_help_is_invoked_on_a_command_with_req
151151
{
152152
new Option<string>("-x")
153153
{
154-
Required = true
154+
IsRequired = true
155155
},
156156
};
157157

src/System.CommandLine/Help/HelpBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private IEnumerable<HelpItem> GetOptionHelpItems(ISymbol symbol)
499499
}
500500

501501
if (symbol is IOption option &&
502-
option.Required)
502+
option.IsRequired)
503503
{
504504
invocation += " (REQUIRED)";
505505
}

src/System.CommandLine/IOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public interface IOption : ISymbol, IValueDescriptor
99
{
1010
IArgument Argument { get; }
1111

12-
bool Required { get; }
12+
bool IsRequired { get; }
1313
}
1414
}

src/System.CommandLine/Option.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public virtual Argument Argument
4444

4545
IArgument IOption.Argument => Argument;
4646

47-
public bool Required { get; set; }
47+
public bool IsRequired { get; set; }
4848

4949
string IValueDescriptor.ValueName => Name;
5050

src/System.CommandLine/Parsing/ParseResultVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void ValidateCommandResult()
208208
.Options)
209209
{
210210
if (option is Option o &&
211-
o.Required &&
211+
o.IsRequired &&
212212
_rootCommandResult!.FindResultFor(o) is null)
213213
{
214214
_errors.Add(

0 commit comments

Comments
 (0)