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

[BUG?] Reused arguments are considered optional

Open iBicha opened this issue 3 years ago • 2 comments

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

iBicha avatar May 31 '22 14:05 iBicha

cc @jonsequitur for visibility

iBicha avatar Jun 22 '22 19:06 iBicha

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:

image

jonsequitur avatar Jun 22 '22 22:06 jonsequitur