Skip to content

Commit 62e1003

Browse files
committed
remove Option.ArgumentDescription and rename Option.ArgumentName to ArgumentHelpName
1 parent e219656 commit 62e1003

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,23 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
4242
),
4343
new Option<string>(aliases: new string[] {"--the-root-option-no-default-arg", "-tronda"}) {
4444
Description = "the-root-option-no-default-description",
45-
ArgumentName = "the-root-option-arg-no-default-arg",
46-
ArgumentDescription = "the-root-option-arg-no-default-description",
45+
ArgumentHelpName = "the-root-option-arg-no-default-arg",
4746
IsRequired = true
4847
},
4948
new Option<string>(aliases: new string[] {"--the-root-option-default-arg", "-troda"}, () => "the-root-option-arg-value")
5049
{
5150
Description = "the-root-option-default-arg-description",
52-
ArgumentName = "the-root-option-arg",
53-
ArgumentDescription = "the-root-option-arg-description"
51+
ArgumentHelpName = "the-root-option-arg",
5452
},
5553
new Option<FileAccess>(aliases: new string[] {"--the-root-option-enum-arg", "-troea"}, () => FileAccess.Read)
5654
{
5755
Description = "the-root-option-description",
58-
ArgumentName = "the-root-option-arg",
59-
ArgumentDescription = "the-root-option-arg-description"
56+
ArgumentHelpName = "the-root-option-arg",
6057
},
6158
new Option<FileAccess>(aliases: new string[] {"--the-root-option-required-enum-arg", "-trorea"}, () => FileAccess.Read)
6259
{
6360
Description = "the-root-option-description",
64-
ArgumentName = "the-root-option-arg",
65-
ArgumentDescription = "the-root-option-arg-description",
61+
ArgumentHelpName = "the-root-option-arg",
6662
IsRequired = true
6763
},
6864
new Option(aliases: new string[] {"--the-root-option-multi-line-description", "-tromld"}) {
@@ -74,6 +70,5 @@ public void Help_describes_default_values_for_complex_root_command_scenario()
7470
GetHelpBuilder(LargeMaxWidth).Write(command);
7571
Approvals.Verify(_console.Out.ToString());
7672
}
77-
7873
}
7974
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public void Arguments_section_is_not_included_if_there_are_only_options_with_arg
514514
{
515515
new Option("-v", "Sets the verbosity.", arity: ArgumentArity.ExactlyOne)
516516
{
517-
ArgumentName = "argument for options"
517+
ArgumentHelpName = "argument for options"
518518
}
519519
};
520520

@@ -530,7 +530,7 @@ public void Arguments_section_includes_configured_argument_aliases()
530530
{
531531
new Option(new[] { "-v", "--verbosity" }, arity: ArgumentArity.ExactlyOne)
532532
{
533-
ArgumentName = "LEVEL",
533+
ArgumentHelpName = "LEVEL",
534534
Description = "Sets the verbosity."
535535
}
536536
};
@@ -1188,7 +1188,7 @@ public void Required_options_are_indicated_when_argument_is_named()
11881188
new Option<string>(new[] {"-r", "--required" })
11891189
{
11901190
IsRequired = true,
1191-
ArgumentName = "ARG"
1191+
ArgumentHelpName = "ARG"
11921192
}
11931193
};
11941194

@@ -1292,7 +1292,7 @@ public void Help_describes_default_value_for_option_with_argument_having_default
12921292
{
12931293
new Option(new[] { "-arg"}, getDefaultValue: () => "the-arg-value")
12941294
{
1295-
ArgumentName = "the-arg"
1295+
ArgumentHelpName = "the-arg"
12961296
}
12971297
};
12981298

src/System.CommandLine.Tests/OptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,18 @@ public void Argument_takes_option_alias_as_its_name_when_it_is_not_provided()
235235
{
236236
var command = new Option("--alias", arity: ArgumentArity.ZeroOrOne);
237237

238-
command.ArgumentName.Should().Be("alias");
238+
command.ArgumentHelpName.Should().Be("alias");
239239
}
240240

241241
[Fact]
242242
public void Argument_retains_name_when_it_is_provided()
243243
{
244244
var option = new Option("-alias", arity: ArgumentArity.ZeroOrOne)
245245
{
246-
ArgumentName = "arg"
246+
ArgumentHelpName = "arg"
247247
};
248248

249-
option.ArgumentName.Should().Be("arg");
249+
option.ArgumentHelpName.Should().Be("arg");
250250
}
251251

252252
[Fact]

src/System.CommandLine/Option.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,30 +88,16 @@ getDefaultValue is null &&
8888
internal virtual Argument Argument
8989
{
9090
get => Arguments.FirstOrDefault() ?? Argument.None;
91-
set
92-
{
93-
for (var i = 0; i < Children.Arguments.Count; i++)
94-
{
95-
Children.Remove(Children.Arguments[i]);
96-
}
97-
98-
AddArgumentInner(value);
99-
}
91+
set => AddArgumentInner(value); // FIX: delete?
10092
}
10193

10294
//TODO: Guard against Argument.None?
103-
public string ArgumentName
95+
public string ArgumentHelpName
10496
{
10597
get => Argument.Name;
10698
set => Argument.Name = value;
10799
}
108100

109-
public string? ArgumentDescription
110-
{
111-
get => Argument.Description;
112-
set => Argument.Description = value;
113-
}
114-
115101
private IEnumerable<Argument> Arguments => Children.OfType<Argument>();
116102

117103
internal bool DisallowBinding { get; set; }

0 commit comments

Comments
 (0)