Make usage and help output configurable #201
Closed
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.
This is a first pass looking to gather feedback on solving #193, #163, #146 and hopefully also #139.
Essentially, this makes use of
text/template
to specify the output format. It introduces abuildUsageForSubcommand
which uses a string builder to build up the usage string that's then interpolated into the Go template.I haven't modified any of the tests and they still all pass, which at the very least suggest the behaviour is the same.
The idea is to then make the template settable through arg, like
func (arg) UsageTemplate() *template.Template {}
, and if no such template is provided thenp.usageTemplate
would use theconst usageTemplate
.The code is a little rough right now, but it's the general direction I'm thinking of. Does this align with what you had in mind?