mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
edcf765d9f
We previously had this weak argument called projectName which let you set a single part of a man page header. Instead do the best we can if the caller doesn't pass us anything, but let the caller specify anything they want.
25 lines
441 B
Markdown
25 lines
441 B
Markdown
# Generating Man Pages For Your Own cobra.Command
|
|
|
|
Generating bash completions from a cobra command is incredibly easy. An example is as follows:
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func main() {
|
|
cmd := &cobra.Command{
|
|
Use: "test",
|
|
Short: "my test program",
|
|
}
|
|
header := &cobra.GenManHeader{
|
|
Title: "MINE",
|
|
Section: "3",
|
|
}
|
|
cmd.GenManTree(header, "/tmp")
|
|
}
|
|
```
|
|
|
|
That will get you a man page `/tmp/test.1`
|