Conversation
abitrolly
commented
Apr 19, 2025
- print usage to stdout when command is not given
- do not mix usage help with errors
- show command description and args order in usage
* print usage to stdout when command is not given * do not mix usage help with errors * show command description and args order in usage
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
=======================================
Coverage 58.50% 58.50%
=======================================
Files 37 37
Lines 4779 4779
=======================================
Hits 2796 2796
Misses 1776 1776
Partials 207 207
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@hugelgupf do these changes make sense? I can leave them in my fork, but it may be useful to have them there. |
|
I attempted to break this up a little, and added some other changes on top.
Any rationale for changing the output writer from |
|
@djdv in 4c1a395 I like separate error codes. The confusing part is that parsing and setting global vars values occurs in a function. Maybe wrapping it all in a struct would be better. I haven't tested the new code, but it seems to me it will print help after errors. Maybe we can use https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript to craft desired output. But I am not sure how to test binaries that are just compiled.
Only help is written to |
|
There was a bad bug in my previous commit: https://github.com/hugelgupf/p9/compare/4c1a3950faedd7f36122ae91e0d19b2af57b8fa6..bcc32f1 abitrolly, I wrote some thoughts on this.
For locality, the variables are defined and described in the scope they're used, and can be passed, rather than globally referenced.
If you checkout or apply that commit, you can run
For parsing errors yes, but not for other errors (it could though). This is internal to On my machine the output is like this:The second command exits with status The third command exits with status
I'd probably stick with go's standard test library for automated testing, but no strong opinion. In that commit, we also have control of the flagset's output which during testing could be some buffer/whatever that we use to compare if needed. (When
Non-ideal in some cases for sure. I've tried replacing it but am not yet sure if my own attempts have been better yet. lol
That seems fair, but I'm also not familiar with the modern conventions. I highly doubt anyone/thing depends on the current behavior of the usage text going to |
I don't trust manual testing. It is too fragile, and hard to remember how the alright look should be.
I believe
Maybe it doesn't worth it. Just ship an improved version and then gradually enhance it.
There are quite a few alternatives, but I am haven't tested the overhead of replacing
These guys should have sent the patch upstream instead of forcing us to make workarounds for their "breaking change". ) |