-
Notifications
You must be signed in to change notification settings - Fork 399
make HelpBuilder and related APIs internal #2563
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
Conversation
…PIs, expose Option.GetDefaultValue
2607cbd
to
e99a785
Compare
@@ -100,6 +100,7 @@ | |||
public System.Collections.Generic.List<System.Action<System.CommandLine.Parsing.OptionResult>> Validators { get; } | |||
public System.Type ValueType { get; } | |||
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context) | |||
public System.Object GetDefaultValue() |
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.
I needed this to be able to avoid using Option.Argument
(internal getter), it contributes to #2526
helpAction.Builder.CustomizeSymbol(option, secondColumnText: "The custom option description"); | ||
helpAction.Builder.CustomizeSymbol(argument, secondColumnText: "The custom argument description"); | ||
|
||
var rootCommand = new Command("name") |
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.
I am using Command
rather than RootCommand
as it allows me to avoid the need of replacing HelpOption
defined in RootCommand.Options
|
||
namespace System.CommandLine.Help | ||
{ | ||
public partial class HelpBuilder | ||
internal static class HelpBuilderExtensions |
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 file was called HelpBuilderExtensions.cs
and we need to be able to copy this code to SDK, so I decided to move all the extension methods used by the builder here
/// <summary> | ||
/// The result of the current parse operation. | ||
/// </summary> | ||
public ParseResult ParseResult { get; } |
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.
It was not used anywhere and the lack of value required a call to ParseResult.Empty()
(internal) so I've just removed it
Ouch, this is going to break several of my apps. |
Another possibility might be to publish the |
…or multiple subcommands (and having multiple parents) used with GetValue(name)
…arents. We can't allow for name duplicates within the same parent (command).CommandResult
} | ||
|
||
[Fact] | ||
public void When_the_same_option_used_in_different_levels_of_the_tree_no_exception_is_thrown() |
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 a test for a bug I've hit while working on dotnet/sdk#49181:
System.InvalidOperationException: Command build has more than one child named "--interactive".
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.
I'd quibble about the test name here. The intent is that the option is correctly attributed to the correct descendant.
{ | ||
if (_symbolsByName!.TryGetValue(symbol.Name, out var node)) | ||
{ | ||
if (symbol.Name == node.Symbol.Name && | ||
symbol.FirstParent?.Symbol is { } parent && | ||
parent == node.Symbol.FirstParent?.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.
A symbol can have multiple parents, so this check was incomplete and wrong.
No description provided.