Fix invalid flag processing when no flags passed on command line #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After first building the license-scanner I decided to install/run it to see the help and what flags were available/documented. However, to my surprise, the executable terminated (exited with no error) and displayed no help.
Debugging this I found that the flag "configurer.UpdateAllFlag" was being retrieved as a
string
(getString()
) despite it being aboolean
flag. Cobra returned no error on the existing code, but returns an empty string (""
) which was being checked for and caused the "return importer.Update(cfg)" method to be called which has nothing to do so it exits (with no help, message or error return code).This PR correctly reads the flag as a Bool and actually causes the desired behavior which displays:
from the root command's RunE() method logic here:
Fixes: #28