command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

UseHost() - can't have subcommand "config"

Open seanadams9 opened this issue 2 years ago • 1 comments

When using UseHost() the hosting action sets up a CliDirective with the name "config". If you have a subcommand with the same name "config" parsing fails with:

An item with the same key has already been added. Key: config System.ArgumentException: An item with the same key has already been added. Key: config at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at System.CommandLine.Parsing.StringExtensions.<ValidTokens>g__AddCommandTokens|8_0(Dictionary2 tokens, CliCommand cmd) at System.CommandLine.Parsing.StringExtensions.ValidTokens(CliCommand command, IReadOnlyList1 directives) at System.CommandLine.Parsing.StringExtensions.Tokenize(IReadOnlyList1 args, CliConfiguration configuration, Boolean inferRootCommand, List1& tokens, List1& errors) at System.CommandLine.Parsing.CliParser.Parse(CliCommand command, IReadOnlyList1 arguments, String rawInput, CliConfiguration configuration) at System.CommandLine.Parsing.CliParser.Parse(CliCommand command, IReadOnlyList1 args, CliConfiguration configuration) at System.CommandLine.CliConfiguration.Parse(IReadOnlyList1 args)

seanadams9 avatar Jun 12 '23 22:06 seanadams9

This bug is more general and affects any directive where the name collides with a command defined on the root.

jonsequitur avatar Jun 12 '23 23:06 jonsequitur