cli icon indicating copy to clipboard operation
cli copied to clipboard

Add section 'Examples'

Open tredoe opened this issue 5 years ago • 5 comments

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 avatar Feb 09 '20 18:02 tredoe

@tredoe could this be solved with a custom help template?

coilysiren avatar Mar 30 '20 23:03 coilysiren

I guess so but the idea was to have the same output for when someone want to add a section of examples.

tredoe avatar Apr 08 '20 06:04 tredoe

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.

coilysiren avatar Apr 25 '20 01:04 coilysiren

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.

stale[bot] avatar Jul 24 '20 03:07 stale[bot]

Closing this as it has become stale.

stale[bot] avatar Aug 23 '20 03:08 stale[bot]

yes I agree with @coilysiren comment on this

dearchap avatar Dec 01 '22 13:12 dearchap