Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 1c3ee92

Browse files
committed
Show help examples
1 parent 3240432 commit 1c3ee92

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ func main() {
6161
}
6262

6363
```
64+
renders a help like
65+
66+
```
67+
Usage: simple-example [flags]
68+
69+
This is a simple example of the cli package.
70+
71+
simple-example flags:
72+
-v sets verbose mode (false)
73+
```
6474

6575
### Subcommands
6676

@@ -114,4 +124,15 @@ func (c *cmd) Subcommands() []cli.Command {
114124
func main() {
115125
cli.RunRoot(&cmd{})
116126
}
127+
```
128+
129+
renders a help like
130+
131+
```
132+
Usage: subcommand [flags]
133+
134+
This is a simple example of subcommands.
135+
136+
Commands:
137+
sub This is a simple subcommand.
117138
```

help.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func renderFlagHelp(fl *flag.FlagSet, w io.Writer) {
1818
var count int
1919
fl.VisitAll(func(f *flag.Flag) {
2020
if count == 0 {
21-
fmt.Fprintf(w, "%v flags:\n", fl.Name())
21+
fmt.Fprintf(w, "\n%v flags:\n", fl.Name())
2222
}
2323

2424
count++

0 commit comments

Comments
 (0)