go-arg
go-arg copied to clipboard
Fix usage writing when using custom version flag
Hi @alexflint , this is a small follow-up to PR #223 :)
I realized that I forgot to update the write usage function, and it was still printing the output of Version() even if a custom --version flag spec is present in the arguments. This is now also fixed and I added more unit tests for help/usage writing.
I also took the opportunity to improve a bit the way version flag specs are scanned for both usage and help writing.
I belive that this PR now fully addresses issue #171 because, when using a custom --version flag, the builtin version string (if any) is not printed anymore in usage and errors.
Fixes #171
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.73%. Comparing base (
dfca71d) to head (851ff4c). Report is 2 commits behind head on master.
:exclamation: Current head 851ff4c differs from pull request most recent head c087d71
Please upload reports for the commit c087d71 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## master #224 +/- ##
=======================================
Coverage 99.72% 99.73%
=======================================
Files 5 5
Lines 727 744 +17
=======================================
+ Hits 725 742 +17
Misses 1 1
Partials 1 1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Rebased on top of the latest master branch.
@alexflint any chance of taking a look a this PR? :)
Thanks!
@hhromic This looks good but I need to look closer because there are quite a few changes (even ignoring the tests -- thanks for adding those)
Hi @alexflint ! I rebased this PR on top of the current master branch in case you are still interested on this fix. I also refactored the unit tests to be closer to the coding style you had already.
EDIT: With this PR, the test suite covers 100.0% of the code (in contrast to 99.8% in current master):
PASS
coverage: 100.0% of statements
ok github.com/alexflint/go-arg 0.025s
Wonderful, thanks for doing this @hhromic