command-line-api
command-line-api copied to clipboard
If an optional positional argument is not specified it may incorrectly be filled with another argument
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:
It assigns the value that is properly assigned to the Program argument also to the not-specified positional arg zArgs
Help output to better illustrate:
Usage:
TestApp Monitor <File> <Program> [<ZArgs>] [options]
Arguments:
<File> File or folder
<Program> Program path
<ZArgs> Arg string to pass
Options:
--Debug turn on debug mode
If a value is given for that it does parse correctly:
Running: 2.0.0-beta4.22272.1
Can you share your test code so we can more easily reproduce this?
No problem attached.
Here is the output generated.
Invoking with args: c:\temp\monitttest, ping
For child: File has value: c:\temp\monitttest
For child: Program has value: ping
For child: ZArgs has value: ping
Note if you only have one required arg rather than two it does not seem to happen (ie removing the program one) Program.cs.txt
Hi,
Just to add another use case.
I have the following Command:
Command abc Arguments: string arg1 string arg2
Options: string --opt1 string --opt2
when invoking with invalid options:
abc --opt3 value3
these values will be considered the value of the arguments arg1
and arg2
.
I have done some debugging and it seems that in the Tokenize method, every time that a token is not in the RootCommand.ValidTokens()
is considered an Argument.