Skip to content

Commit 71d54df

Browse files
committed
add suggestion
1 parent 944ca25 commit 71d54df

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,26 @@ urfave/cli-docs/v3 is an extended documentation library for use with urfave/cli/
2525
3. Now use it e.g. to generate markdown document from a command
2626

2727
```go
28+
package main
29+
30+
import (
31+
"fmt"
32+
"os"
33+
34+
docs "github.com/urfave/cli-docs/v3"
35+
cli "github.com/urfave/cli/v3"
36+
)
37+
2838
func main() {
29-
app := newApp()
39+
app := &cli.Command{
40+
Name: "greet",
41+
Usage: "say a greeting",
42+
Action: func(c *cli.Context) error {
43+
fmt.Println("Greetings")
44+
return nil
45+
},
46+
}
47+
3048
md, err := docs.ToMarkdown(app)
3149
if err != nil {
3250
panic(err)
@@ -42,3 +60,23 @@ func main() {
4260
}
4361
}
4462
```
63+
64+
This will create a file `cli-docs.md` with content:
65+
66+
````md
67+
# CLI
68+
69+
# NAME
70+
71+
greet - say a greeting
72+
73+
# SYNOPSIS
74+
75+
greet
76+
77+
**Usage**:
78+
79+
```
80+
greet [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...]
81+
```
82+
````

0 commit comments

Comments
 (0)