File: man_docs.md

package info (click to toggle)
golang-github-dnephin-cobra 1.5%2Bgit20161103.0.a3c0924-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 400 kB
  • sloc: makefile: 5
file content (26 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Generating Man Pages For Your Own cobra.Command

Generating man pages from a cobra command is incredibly easy. An example is as follows:

```go
package main

import (
	"github.com/spf13/cobra"
	"github.com/spf13/cobra/doc"
)

func main() {
	cmd := &cobra.Command{
		Use:   "test",
		Short: "my test program",
	}
	header := &cobra.GenManHeader{
		Title: "MINE",
		Section: "3",
	}
	doc.GenManTree(cmd, header, "/tmp")
}
```

That will get you a man page `/tmp/test.1`