File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,26 @@ urfave/cli-docs/v3 is an extended documentation library for use with urfave/cli/
25
25
3 . Now use it e.g. to generate markdown document from a command
26
26
27
27
``` 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
+
28
38
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
+
30
48
md , err := docs.ToMarkdown (app)
31
49
if err != nil {
32
50
panic (err)
@@ -42,3 +60,23 @@ func main() {
42
60
}
43
61
}
44
62
```
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
+ ````
You can’t perform that action at this time.
0 commit comments