-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Print the long options of the required flags missing #1126
Conversation
Also, would it be an idea to export the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct, but it's not clear from the MR description what this is fixing.
Please add a regression test to prove that this change fixes the incorrect behavior you were seeing.
As a note, if we end up accepting this, I believe it is relevant for the v2/master branch as well. |
This adds a test verifying that the requiredFlagsError does contain the long option of the missing flag, instead of the short option and a space, which was the old behaviour. Signed-off-by: Ole Petter <[email protected]>
The error message collected by 'checkRequiredFlags()' now sets the name of the flags to the long option given in the 'Name: <somecommand>' field. This change is introduced to fix up an error where printing the error in the case of a missing required flag looks like: ``` Required flags " n, t" not set ``` Whilst the expected behaviour is: ``` Required flags "<long-name1>, <long-name2>" not set ``` Signed-off-by: Ole Petter <[email protected]>
Acrually, I was not able to reproduce this on master. The code has changed a little though, so the explicit string splitting is not done anylonger, and the name is returned directly, so the situation seems to be fine there. I did cherry the test over just to be sure, and it passed. Do you still want a PR for it on master (the test only that is). |
@oleorhagen Thanks for checking v2 as well. If you wanted to submit a PR to add the test case to master, that would be awesome! |
StringSliceFlag needs to be a pointer, and not a struct. See: urfave#1126 for a description of the regression tested for. Signed-off-by: Ole Petter <[email protected]>
StringSliceFlag needs to be a pointer, and not a struct. Also formatted the test. See: urfave#1126 for a description of the regression tested for. Signed-off-by: Ole Petter <[email protected]>
StringSliceFlag needs to be a pointer, and not a struct. Also formatted the test. See: urfave/cli#1126 for a description of the regression tested for. Signed-off-by: Ole Petter <[email protected]>
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
This fixes a formatting bug in the v1 required flags error message
Which issue(s) this PR fixes:
Formatting error in the requireflags error message
Special notes for your reviewer:
I at least think this is a bug. The short option behaviour is a little odd.
Testing
Only tested manually, see the commit message for output.
Release Notes