command-line-api
command-line-api copied to clipboard
[BUG?] Reused arguments are considered optional
I see in the help builder that an argument used in multiple commands is flagged as optional in usage help
https://github.com/dotnet/command-line-api/blob/55dbf39074a7563e25e3409c9feb7afb8c8d2cc4/src/System.CommandLine/Help/HelpBuilder.cs#L332
bool IsOptional(Argument argument) =>
IsMultiParented(argument) ||
argument.Arity.MinimumNumberOfValues == 0;
Is there a reason for this? We reuse arguments when it makes sense between commands, and they are still required. I believe this is a bug unless I'm missing something
cc @jonsequitur for visibility
Off the top of my head, I'm not sure what the reason for this is, but the argument being shown as optional (i.e. surrounded by [ ]) is definitely misleading: