2016-06-09 15:33:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2016-09-08 17:11:39 +00:00
|
|
|
"github.com/docker/docker/cli/command"
|
|
|
|
"github.com/docker/docker/cli/command/commands"
|
2016-06-23 15:25:51 +00:00
|
|
|
"github.com/docker/docker/pkg/term"
|
|
|
|
"github.com/spf13/cobra"
|
2016-06-09 15:33:28 +00:00
|
|
|
"github.com/spf13/cobra/doc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func generateManPages(path string) error {
|
|
|
|
header := &doc.GenManHeader{
|
|
|
|
Title: "DOCKER",
|
|
|
|
Section: "1",
|
|
|
|
Source: "Docker Community",
|
|
|
|
}
|
2016-06-23 15:25:51 +00:00
|
|
|
|
|
|
|
stdin, stdout, stderr := term.StdStreams()
|
2016-09-08 17:11:39 +00:00
|
|
|
dockerCli := command.NewDockerCli(stdin, stdout, stderr)
|
2016-06-23 15:25:51 +00:00
|
|
|
cmd := &cobra.Command{Use: "docker"}
|
2016-09-08 17:11:39 +00:00
|
|
|
commands.AddCommands(cmd, dockerCli)
|
2016-06-23 15:25:51 +00:00
|
|
|
|
2016-06-09 15:33:28 +00:00
|
|
|
cmd.DisableAutoGenTag = true
|
|
|
|
return doc.GenManTreeFromOpts(cmd, doc.GenManTreeOptions{
|
|
|
|
Header: header,
|
|
|
|
Path: path,
|
|
|
|
CommandSeparator: "-",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
path := "/tmp"
|
|
|
|
if len(os.Args) > 1 {
|
|
|
|
path = os.Args[1]
|
|
|
|
}
|
|
|
|
fmt.Printf("Generating man pages into %s\n", path)
|
|
|
|
if err := generateManPages(path); err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Failed to generate man pages: %s\n", err.Error())
|
|
|
|
}
|
|
|
|
}
|