-
Notifications
You must be signed in to change notification settings - Fork 27
fix: sub-commands styling #47
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves sub-command styling in help/man outputs, displays full command paths in examples, and refactors testing to use pointer‐based root commands.
- Replace generic placeholder names in golden files and add new golden outputs for nested subcommands
- Update
styleUsage
andstyleExample
to use full paths andUseLine()
, and refactorisSubCommand
- Simplify version logic in
Execute
viabuildVersion
and convert many tests to usetoMkroot
helpers
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
testdata/TestSetup/with_subcommands/*.golden | Updated expected help outputs for subcommands and examples |
testdata/TestSetup/complete/man.golden | Changed manpage title and usage to include man subcommand |
help.go | Switched to UseLine() for usage, enhanced subcommand styling, updated isSubCommand signature |
fang.go | Extracted version-building logic into buildVersion and wire-up in Execute |
fang_test.go | Refactored tests to use toMkroot wrappers and Go 1.24’s T.Context() |
example/main.go | Added examples for nested subcommands |
Comments suppressed due to low confidence (2)
fang.go:147
- The new
buildVersion
function has branching logic for default and VCS-based versions; consider adding unit tests to cover both code paths.
func buildVersion(opts settings) string {
help.go:288
cleanArgs
currently accumulates all tokens including flags and quoted strings, which can break command traversal; consider appending only actual subcommand names to the path.
cleanArgs = append(cleanArgs, arg)
Hi @caarlos0 As Go uses the N-1 support matrix typically it would be great to stay on 1.23 until 1.25 is GA and have other libs to not be forced to jump on latest. |
this properly handles examples to sub commands, as well as show the full path in places it probably should.
on top of that, it improves testing, which wasn't working properly due to root cmd not being a pointer.
Looks like this:
closes #45
closes #44