go-arg icon indicating copy to clipboard operation
go-arg copied to clipboard

Fix usage writing when using custom version flag

Open hhromic opened this issue 2 years ago • 3 comments

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

hhromic avatar Jul 15 '23 13:07 hhromic

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.

codecov-commenter avatar Jul 15 '23 13:07 codecov-commenter

Rebased on top of the latest master branch. @alexflint any chance of taking a look a this PR? :) Thanks!

hhromic avatar Jan 18 '24 23:01 hhromic

@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)

alexflint avatar Jan 22 '24 15:01 alexflint

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

hhromic avatar Jun 29 '24 23:06 hhromic

Wonderful, thanks for doing this @hhromic

alexflint avatar Jun 30 '24 16:06 alexflint