Skip to content

Commit cc1c3a5

Browse files
WIP
1 parent 59201ca commit cc1c3a5

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

src/System.CommandLine.Subsystems/ValueProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ private bool TryGetValue<T>(CliSymbol symbol, out T? value)
3434
return false;
3535
}
3636

37-
public T? GetValue<T>(CliDataSymbol dataSymbol)
38-
=> GetValueInternal<T>(dataSymbol);
37+
public T? GetValue<T>(CliValueSymbol valueSymbol)
38+
=> GetValueInternal<T>(valueSymbol);
3939

4040
private T? GetValueInternal<T>(CliSymbol? symbol)
4141
{
@@ -53,9 +53,9 @@ not null when TryGetValue<T>(symbol, out var value)
5353
// configuration values go here in precedence
5454
//not null when GetDefaultFromEnvironmentVariable<T>(symbol, out var envName)
5555
// => UseValue(symbol, GetEnvByName(envName)),
56-
not null when TryGetAnnotation(symbol, ValueAnnotations.DefaultValueCalculation, out Func<T?>? defaultValueCalculation)
56+
not null when symbol.TryGetAnnotation(ValueAnnotations.DefaultValueCalculation, out Func<T?>? defaultValueCalculation)
5757
=> UseValue(symbol, CalculatedDefault<T>(symbol, (Func<T?>)defaultValueCalculation)),
58-
not null when TryGetAnnotation(symbol, ValueAnnotations.DefaultValue, out T? explicitValue)
58+
not null when symbol.TryGetAnnotation(ValueAnnotations.DefaultValue, out T? explicitValue)
5959
=> UseValue(symbol, explicitValue),
6060
null => throw new ArgumentNullException(nameof(symbol)),
6161
_ => UseValue(symbol, default(T))

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.CommandResult
142+
result.CommandValueResult
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.CommandResultInternal
191+
result.CommandResult
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.CommandResultInternal
213+
result.CommandResult
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.CommandResultInternal
425+
result.CommandResult
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.CommandResultInternal
443+
result.CommandResult
444444
.Children
445445
.Should()
446446
.ContainSingle(o =>
447447
((CliOptionResultInternal)o).Option.Name == "--inner1" &&
448448
o.Tokens.Single().Value == "argument1");
449-
result.CommandResultInternal
449+
result.CommandResult
450450
.Children
451451
.Should()
452452
.ContainSingle(o =>

src/System.CommandLine/ParseResult.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ internal ParseResult(
5252
Configuration = configuration;
5353
_rootCommandResult = rootCommandResult;
5454
// TODO: Why do we need this?
55-
CommandResultInternal = commandResultInternal;
56-
CommandResult = commandResultInternal.CommandResult;
55+
CommandResult = commandResultInternal;
5756
this.valueResultDictionary = valueResultDictionary;
5857
// TODO: invocation
5958
/*
@@ -102,22 +101,22 @@ internal ParseResult(
102101
/// <summary>
103102
/// A result indicating the command specified in the command line input.
104103
/// </summary>
105-
internal CommandResult CommandResult { get; }
104+
internal CliCommandResultInternal CommandResult { get; }
106105

107-
private CommandValueResult? commandValueResult = null;
108-
public CommandValueResult CommandValueResult
106+
private CliCommandResult? commandValueResult = null;
107+
public CliCommandResult CommandValueResult
109108
{
110109
get
111110
{
112111
if (commandValueResult is null)
113112
{
114-
commandValueResult = new CommandValueResult(CommandResult);
113+
commandValueResult = new CliCommandResult(CommandResult.Command, CommandResult.Tokens.Select(t=>t.Location) );
115114
}
116115
return commandValueResult;
117116
}
118117
}
119118

120-
public IEnumerable<ValueResult> AllValueResults
119+
public IEnumerable<CliValueResult> AllValueResults
121120
=> valueResultDictionary.Values;
122121

123122

src/System.CommandLine/Parsing/CliValueResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal CliValueResult(
4141
ValueResultOutcome outcome,
4242
// TODO: Error should be an Enumerable<Error> and perhaps should not be here at all, only on ParseResult
4343
string? error = null)
44-
: this((CliSymbol)argument, value, locations, outcome, error)
44+
: this((CliValueSymbol)argument, value, locations, outcome, error)
4545
{ }
4646

4747
/// <summary>
@@ -59,13 +59,13 @@ internal CliValueResult(
5959
ValueResultOutcome outcome,
6060
// TODO: Error should be an Enumerable<Error> and perhaps should not be here at all, only on ParseResult
6161
string? error = null)
62-
: this((CliSymbol)option, value, locations, outcome, error)
62+
: this((CliValueSymbol)option, value, locations, outcome, error)
6363
{ }
6464

6565
/// <summary>
6666
/// The CliSymbol the value is for. This is always a CliOption or CliArgument.
6767
/// </summary>
68-
public CliDataSymbol ValueSymbol { get; }
68+
public CliSymbol ValueSymbol { get; }
6969

7070
internal object? Value { get; }
7171

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.CommandResultInternal;
46+
var commandResult = parseResult.CommandResult;
4747
while (commandResult is not null)
4848
{
4949
var command = commandResult.Command;

0 commit comments

Comments
 (0)