...

Text file src/github.com/spf13/cobra/site/content/docgen/man.md

Documentation: github.com/spf13/cobra/site/content/docgen

     1# Generating Man Pages For Your Own cobra.Command
     2
     3Generating man pages from a cobra command is incredibly easy. An example is as follows:
     4
     5```go
     6package main
     7
     8import (
     9	"log"
    10
    11	"github.com/spf13/cobra"
    12	"github.com/spf13/cobra/doc"
    13)
    14
    15func main() {
    16	cmd := &cobra.Command{
    17		Use:   "test",
    18		Short: "my test program",
    19	}
    20	header := &doc.GenManHeader{
    21		Title: "MINE",
    22		Section: "3",
    23	}
    24	err := doc.GenManTree(cmd, header, "/tmp")
    25	if err != nil {
    26		log.Fatal(err)
    27	}
    28}
    29```
    30
    31That will get you a man page `/tmp/test.3`

View as plain text