cli
cli copied to clipboard
Add section 'Examples'
Checklist
- [x] Are you running the latest v2 release?
- [x] Did you check the manual for your release?
- [x] Did you perform a search about this feature?
What problem does this solve?
- To have a place where look for examples of usage.
- After of a period of time without using a tool you could forget some flags, and the fast way to remind it is reading examples.
Solution description
Add a field Examples to Command; Examples would be of type []Example:
type Example struct {
Line string
Usage string
}
where Usage is the optional text to explain the Line, and Line contains the full example of code.
When the help is showed, it should show the section EXAMPLE or EXAMPLES just after of section 'OPTIONS'.
Describe alternatives you've considered
To add the examples on the section 'Description', but it is easier to find if there is a specific section for it.
@tredoe could this be solved with a custom help template?
I guess so but the idea was to have the same output for when someone want to add a section of examples.
That's fair! Ultimately I think adding an Example struct to the library would be heavy lift for this use-case, and would really prefer people use custom help templates.
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.
Closing this as it has become stale.
yes I agree with @coilysiren comment on this