Skip to content

Commit 2739729

Browse files
Updates to match main-powederhouse
1 parent cc1c3a5 commit 2739729

File tree

7 files changed

+19
-102
lines changed

7 files changed

+19
-102
lines changed

src/System.CommandLine.Subsystems.Tests/ValueSubsystemTests.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,8 @@ namespace System.CommandLine.Subsystems.Tests;
1010

1111
public class ValueSubsystemTests
1212
{
13-
//[Fact]
14-
//public void ValueSubsystem_is_activated_by_default()
15-
//{
16-
// CliRootCommand rootCommand = [
17-
// new CliCommand("x")
18-
// {
19-
// new CliOption<string>("--opt1")
20-
// }];
21-
// var configuration = new CliConfiguration(rootCommand);
22-
// var subsystem = new ValueProvider();
23-
// var input = "x --opt1 Kirk";
24-
// var args = CliParser.SplitCommandLine(input).ToList();
13+
// TODO: Add various default value tests
2514

26-
// Subsystem.Initialize(subsystem, configuration, args);
27-
// var parseResult = CliParser.Parse(rootCommand, args[0], configuration);
28-
// var isActive = Subsystem.GetIsActivated(subsystem, parseResult);
29-
30-
// isActive.Should().BeTrue();
31-
//}
3215
/* Hold these tests until we determine if ValueSubsystem is replaceable
3316
[Fact]
3417
public void ValueSubsystem_returns_values_that_are_entered()

src/System.CommandLine.Subsystems/Directives/DiagramSubsystem.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ private static void Diagram(
6767
{
6868
builder.Append('!');
6969
}
70-
*/
71-
// TODO: Directives
72-
/*
70+
*/
71+
// TODO: Directives
72+
/*
7373
switch (symbolResult)
7474
{
7575
case DirectiveResult { Directive: not DiagramDirective }:
7676
break;
7777
*/
7878

79-
// TODO: This logic is deeply tied to internal types/properties. These aren't things we probably want to expose like SymbolNode. See #2349 for alternatives
80-
/*
79+
// TODO: This logic is deeply tied to internal types/properties. These aren't things we probably want to expose like SymbolNode. See #2349 for alternatives
80+
/*
8181
case ArgumentResult argumentResult:
8282
{
8383
var includeArgumentName =
@@ -177,6 +177,5 @@ private static void Diagram(
177177
}
178178
}
179179
}
180-
}
181180
*/
182181
}

src/System.CommandLine.Subsystems/Pipeline.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static Pipeline CreateEmpty()
5656

5757
private Pipeline()
5858
{
59-
//Value = new ValueProvider();
6059
Response = new ResponseSubsystem();
6160
Invocation = new InvocationSubsystem();
6261
Validation = new ValidationSubsystem();
@@ -182,11 +181,6 @@ public ErrorReportingSubsystem? ErrorReporting
182181
/// </summary>
183182
public InvocationSubsystem? Invocation { get; }
184183

185-
///// <summary>
186-
///// Gets the value subsystem which manages entered and default values.
187-
///// </summary>
188-
//public ValueProvider Value { get; }
189-
190184
/// <summary>
191185
/// Gets the response file subsystem
192186
/// </summary>

src/System.CommandLine.Tests/ParserTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void Option_short_forms_can_be_bundled()
139139

140140
var result = CliParser.Parse(command, "the-command -xyz");
141141

142-
result.CommandValueResult
142+
result.CommandResult
143143
.ValueResults
144144
.Select(o => ((CliValueResult)o).ValueSymbol.Name)
145145
.Should()
@@ -188,7 +188,7 @@ public void Option_long_forms_do_not_get_unbundled()
188188

189189
var result = CliParser.Parse(command, "the-command --xyz");
190190

191-
result.CommandResult
191+
result.CommandResultInternal
192192
.Children
193193
.Select(o => ((CliOptionResultInternal)o).Option.Name)
194194
.Should()
@@ -210,7 +210,7 @@ public void Options_do_not_get_unbundled_unless_all_resulting_options_would_be_v
210210

211211
ParseResult result = CliParser.Parse(outer, "outer inner -abc");
212212

213-
result.CommandResult
213+
result.CommandResultInternal
214214
.Tokens
215215
.Select(t => t.Value)
216216
.Should()
@@ -422,7 +422,7 @@ public void When_an_option_is_not_respecified_but_limit_is_reached_then_the_foll
422422
.Should()
423423
.BeEquivalentTo("carrot");
424424

425-
result.CommandResult
425+
result.CommandResultInternal
426426
.Tokens
427427
.Select(t => t.Value)
428428
.Should()
@@ -440,13 +440,13 @@ public void Command_with_multiple_options_is_parsed_correctly()
440440

441441
var result = CliParser.Parse(command, "outer --inner1 argument1 --inner2 argument2");
442442

443-
result.CommandResult
443+
result.CommandResultInternal
444444
.Children
445445
.Should()
446446
.ContainSingle(o =>
447447
((CliOptionResultInternal)o).Option.Name == "--inner1" &&
448448
o.Tokens.Single().Value == "argument1");
449-
result.CommandResult
449+
result.CommandResultInternal
450450
.Children
451451
.Should()
452452
.ContainSingle(o =>

src/System.CommandLine/ParseResult.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ internal ParseResult(
5252
Configuration = configuration;
5353
_rootCommandResult = rootCommandResult;
5454
// TODO: Why do we need this?
55-
CommandResult = commandResultInternal;
55+
CommandResultInternal = commandResultInternal;
56+
CommandResult = commandResultInternal.CommandResult;
5657
this.valueResultDictionary = valueResultDictionary;
5758
// TODO: invocation
5859
/*
@@ -101,25 +102,10 @@ internal ParseResult(
101102
/// <summary>
102103
/// A result indicating the command specified in the command line input.
103104
/// </summary>
104-
internal CliCommandResultInternal CommandResult { get; }
105-
106-
private CliCommandResult? commandValueResult = null;
107-
public CliCommandResult CommandValueResult
108-
{
109-
get
110-
{
111-
if (commandValueResult is null)
112-
{
113-
commandValueResult = new CliCommandResult(CommandResult.Command, CommandResult.Tokens.Select(t=>t.Location) );
114-
}
115-
return commandValueResult;
116-
}
117-
}
118-
119-
public IEnumerable<CliValueResult> AllValueResults
120-
=> valueResultDictionary.Values;
121-
105+
// TODO: Update SymbolLookupByName to use CommandValueResult, then remove
106+
internal CliCommandResultInternal CommandResultInternal { get; }
122107

108+
public CliCommandResult CommandResult { get; }
123109

124110
/// <summary>
125111
/// The configuration used to produce the parse result.

src/System.CommandLine/Parsing/CliValueResult.cs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace System.CommandLine.Parsing;
1010
/// </summary>
1111
public class CliValueResult : CliSymbolResult
1212
{
13-
private CliValueResult(
13+
internal CliValueResult(
1414
CliValueSymbol valueSymbol,
1515
object? value,
1616
IEnumerable<Location> locations,
@@ -26,42 +26,6 @@ private CliValueResult(
2626
Error = error;
2727
}
2828

29-
/// <summary>
30-
/// Creates a new ValueResult instance
31-
/// </summary>
32-
/// <param name="argument">The CliArgument the value is for.</param>
33-
/// <param name="value">The entered value.</param>
34-
/// <param name="locations">The locations list.</param>
35-
/// <param name="outcome">True if parsing and converting the value was successful.</param>
36-
/// <param name="error">The CliError if parsing or converting failed, otherwise null.</param>
37-
internal CliValueResult(
38-
CliArgument argument,
39-
object? value,
40-
IEnumerable<Location> locations,
41-
ValueResultOutcome outcome,
42-
// TODO: Error should be an Enumerable<Error> and perhaps should not be here at all, only on ParseResult
43-
string? error = null)
44-
: this((CliValueSymbol)argument, value, locations, outcome, error)
45-
{ }
46-
47-
/// <summary>
48-
/// Creates a new ValueResult instance
49-
/// </summary>
50-
/// <param name="option">The CliOption the value is for.</param>
51-
/// <param name="value">The entered value.</param>
52-
/// <param name="locations">The locations list.</param>
53-
/// <param name="outcome">True if parsing and converting the value was successful.</param>
54-
/// <param name="error">The CliError if parsing or converting failed, otherwise null.</param>
55-
internal CliValueResult(
56-
CliOption option,
57-
object? value,
58-
IEnumerable<Location> locations,
59-
ValueResultOutcome outcome,
60-
// TODO: Error should be an Enumerable<Error> and perhaps should not be here at all, only on ParseResult
61-
string? error = null)
62-
: this((CliValueSymbol)option, value, locations, outcome, error)
63-
{ }
64-
6529
/// <summary>
6630
/// The CliSymbol the value is for. This is always a CliOption or CliArgument.
6731
/// </summary>
@@ -89,15 +53,6 @@ internal CliValueResult(
8953
? default
9054
: Value;
9155

92-
93-
/// <summary>
94-
/// Gets the locations at which the tokens that made up the value appeared.
95-
/// </summary>
96-
/// <remarks>
97-
/// This needs to be a collection because collection types have multiple tokens and they will not be simple offsets when response files are used.
98-
/// </remarks>
99-
public IEnumerable<Location> Locations { get; }
100-
10156
/// <summary>
10257
/// True when parsing and converting the value was successful
10358
/// </summary>

src/System.CommandLine/Parsing/SymbolLookupByName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private List<CommandCache> BuildCache(ParseResult parseResult)
4343
return cache;
4444
}
4545
cache = [];
46-
var commandResult = parseResult.CommandResult;
46+
var commandResult = parseResult.CommandResultInternal;
4747
while (commandResult is not null)
4848
{
4949
var command = commandResult.Command;

0 commit comments

Comments
 (0)