Skip to content
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

[option] fix print helper msg twice bug, close #37 #50

Merged
merged 1 commit into from
Jun 18, 2021
Merged

[option] fix print helper msg twice bug, close #37 #50

merged 1 commit into from
Jun 18, 2021

Conversation

benja-wu
Copy link
Contributor

@benja-wu benja-wu commented Jun 18, 2021

  • In pflag pkg, line 1129 says The return value will be ErrHelp if -help was set but not defined. So in the original implementation, we use this err type as a signal for us to print the usage message.
  • Before pflag.Parse() return ErrHelp, it actually prints to the stdout with function usage line 927
  • So this is the reason why it will double-print the usage message.

Here is what the solution has done:

  1. Add helper define. So it won't return ErrHelp.
  2. In our option.Parse() function, the function's action change to if pflag parsing found error, then return this err and print to std, exit at last.

Note the original implementation treats pflag's other type return error as a normal condition, and allows Easegress to continue processing. I would like to know the former design's consideration.

@benja-wu benja-wu added the bug Something isn't working label Jun 18, 2021
@benja-wu benja-wu requested a review from xxx7xxxx June 18, 2021 11:20
@xxx7xxxx xxx7xxxx merged commit 0c189ac into easegress-io:main Jun 18, 2021
@benja-wu benja-wu added this to the v1.0.1 milestone Jun 18, 2021
@benja-wu benja-wu deleted the print branch June 19, 2021 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants