Skip to content

Conversation

@adamsitnik
Copy link
Member

No description provided.

@adamsitnik adamsitnik requested a review from jonsequitur May 27, 2025 16:12
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()
Copy link
Member Author

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")
Copy link
Member Author

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
Copy link
Member Author

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; }
Copy link
Member Author

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

@KalleOlaviNiemitalo
Copy link

Ouch, this is going to break several of my apps.

@jonsequitur
Copy link
Contributor

Ouch, this is going to break several of my apps.

Another possibility might be to publish the HelpBuilder as a separate package.

…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()
Copy link
Member Author

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".

Copy link
Contributor

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 (symbol.Name == node.Symbol.Name &&
symbol.FirstParent?.Symbol is { } parent &&
parent == node.Symbol.FirstParent?.Symbol)
Copy link
Member Author

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.

@adamsitnik adamsitnik merged commit 8363e58 into dotnet:main May 29, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants