Fix 2257 - Remove incorrect flag check#2280
Conversation
If the argument passed with a command isn't a sub command, there are two checks performed - check if the command has a default command, and check if the argument passed is a flag. In the case that the default command doesn't exist, and the argument passed is the name of a flag, the sub command resolves to nil, which it was previously as well. Implying the check for the flag name doesn't have affect the sub command resolution. Since a default command doesn't exist, the cmd.parsedArgs list ends up with an empty argument as its zeroth element. This commit removes the flag name check
|
@MohitPanchariya The Release Notes paragraph cannot be empty. Either fill it with a summary of your change (if it's user facing and worth documentation). Otherwise put from template:
|
|
@MohitPanchariya Can you add a test case with the same code as you posted above ? That would ensure that any changes in the future wont regress this fix. |
|
@dearchap Just saw the comments today because I kept wondering why the PR wasn't reviewed yet and decided to take a look. I likely missed the mail. I will try to address the comments over the weekend. |
|
@dearchap Added a test case. @yassinebenaid Since its not a change in the expected behavior, or interface, I put |
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
Current Behavior
If the argument passed with a command isn't a sub command, there are two checks performed - check if the command has a default command, and check if the argument passed is a flag.
In the case that the default command doesn't exist, and the argument passed is the name of a flag, the sub command resolves to nil, which it was previously as well. Implying the check for the flag name doesn't have affect the sub command resolution.
Since a default command doesn't exist, the cmd.parsedArgs list ends up with an empty argument as its zeroth element.
Changed Behavior
Which issue(s) this PR fixes:
(REQUIRED)
Fixes #2257
Testing
(fill-in or delete this section)
Tested the changes locally with the following program
Current state (observe the empty string in the arguments list)
With the change,
Release Notes
(REQUIRED)