-
Notifications
You must be signed in to change notification settings - Fork 403
Support for ValueResult as public type to carry value and location #2372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ValueResult as public type to carry value and location #2372
Conversation
@@ -1,7 +1,9 @@ | |||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | |||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | |||
|
|||
using System.CommandLine.Directives; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of my confusion. If I look at dotnet:main-powderhouse, I see this line present, as well as the files DiagramSubsystemTests.cs, etc.
ba99c86
to
9d83bd3
Compare
OptionResult and ArgumentResult access internal data and ValueResult is a public face for the data and location.
9d83bd3
to
204a997
Compare
new CliArgument<string[]>("arg2") | ||
} | ||
}; | ||
var command = new CliCommand( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove newline
} | ||
}; | ||
|
||
ParseResult result = CliParser.Parse(command, new[] { "the-command", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check whitespace
} | ||
*/ | ||
*/ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line
@@ -23,6 +23,7 @@ public void The_tokenizer_can_handle_single_option() | |||
List<CliToken> tokens = null; | |||
List<string> errors = null; | |||
Tokenizer.Tokenize(args, command, new CliConfiguration(command), true, out tokens, out errors); | |||
Tokenizer.Tokenize(args, command, new CliConfiguration(command), true, out tokens, out errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line really doubled?
@@ -44,6 +47,7 @@ public sealed class ParseResult | |||
Configuration = configuration; | |||
_rootCommandResult = rootCommandResult; | |||
CommandResult = commandResult; | |||
this.valueResultDictionary = valueResults; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably do not need this this
@@ -159,6 +165,9 @@ public IReadOnlyList<string> UnmatchedTokens | |||
public override string ToString() => ParseDiagramAction.Diagram(this).ToString(); | |||
*/ | |||
|
|||
public ValueResult? GetValueResult(CliSymbol symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider TryGetValue here
/// <summary> | ||
/// The argument to which the result applies. | ||
/// </summary> | ||
public CliArgument Argument { get; } | ||
|
||
internal bool ArgumentLimitReached => Argument.Arity.MaximumNumberOfValues == (_tokens?.Count ?? 0); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up usings
var dict = new Dictionary<CliSymbol, ValueResult>(); | ||
foreach (KeyValuePair<CliSymbol, SymbolResult> pair in this) | ||
{ | ||
var result = pair.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace
@@ -0,0 +1,17 @@ | |||
// Copyright (c) .NET Foundation and contributors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding this code to ArgumentResult
Also, be sure the ValueResultOutcome method is used
20849d6
to
5d1e815
Compare
ee98942
to
67fc72a
Compare
The exe name appears to differ in CI
67fc72a
to
9ae597c
Compare
I am having an issue where the base of this merge is not what I am expecting. You can see the problem in System.CommandLine.Subsystems/Directives/DirectiveSubsystem.cs which exists in dotnet/command-line-api, but appears as completely fresh code in this PR. Another example is that ParserTests.cs has a bunch of whitespace fixes made by @mhutch that do not appear in the base of this PR.
I either did something dumb or I have lost my mind.
Commits in this PR also need to be cleaned up, so it is not ready to go, but I wanted to put this out so I could get help resolving this.