github.com/portworx/docker@v1.12.1/man/generate.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/docker/docker/cli/cobraadaptor" 8 cliflags "github.com/docker/docker/cli/flags" 9 "github.com/spf13/cobra/doc" 10 ) 11 12 func generateManPages(path string) error { 13 header := &doc.GenManHeader{ 14 Title: "DOCKER", 15 Section: "1", 16 Source: "Docker Community", 17 } 18 flags := &cliflags.ClientFlags{ 19 Common: cliflags.InitCommonFlags(), 20 } 21 cmd := cobraadaptor.NewCobraAdaptor(flags).GetRootCommand() 22 cmd.DisableAutoGenTag = true 23 return doc.GenManTreeFromOpts(cmd, doc.GenManTreeOptions{ 24 Header: header, 25 Path: path, 26 CommandSeparator: "-", 27 }) 28 } 29 30 func main() { 31 path := "/tmp" 32 if len(os.Args) > 1 { 33 path = os.Args[1] 34 } 35 fmt.Printf("Generating man pages into %s\n", path) 36 if err := generateManPages(path); err != nil { 37 fmt.Fprintf(os.Stderr, "Failed to generate man pages: %s\n", err.Error()) 38 } 39 }