dotnet / dotnet/command-line-api

If an optional positional argument is not specified it may incorrectly be filled with another argument

Open
#1,879 3 comments 0 reactions 0 assignees View on GitHub
Area-Parser and Binder bug
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Can put together a repro case if this bug is not obvious (and im not making a mistake) but it seems pretty easy to cause.

Given the args array to InvokeAsync of:
![image](https://user-images.githubusercontent.com/1643324/197159807-6d3e22dc-1a42-405c-8afa-bcdec4ff2097.png)

It assigns the value that is properly assigned to the Program argument also to the not-specified positional arg zArgs
![image](https://user-images.githubusercontent.com/1643324/197160489-6342cecd-36df-4d0c-89ef-268a4af10029.png)

Help output to better illustrate:
```
Usage:
TestApp Monitor [] [options]

Arguments:
File or folder
Program path
Arg string to pass

Options:
--Debug turn on debug mode
```
If a value is given for that it does parse correctly:

![image](https://user-images.githubusercontent.com/1643324/197161087-7bc2d16c-82c6-4c7e-bc8b-6f27014e5064.png)

Running: 2.0.0-beta4.22272.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.