(opts *options)
| 27 | } |
| 28 | |
| 29 | func gen(opts *options) error { |
| 30 | log.SetFlags(0) |
| 31 | |
| 32 | dockerCLI, err := command.NewDockerCli() |
| 33 | if err != nil { |
| 34 | return err |
| 35 | } |
| 36 | cmd := &cobra.Command{ |
| 37 | Use: "docker [OPTIONS] COMMAND [ARG...]", |
| 38 | Short: "The base command for the Docker CLI.", |
| 39 | } |
| 40 | |
| 41 | clientOpts, _ := cli.SetupRootCommand(cmd) |
| 42 | if err := dockerCLI.Initialize(clientOpts); err != nil { |
| 43 | return err |
| 44 | } |
| 45 | commands.AddCommands(cmd, dockerCLI) |
| 46 | // TODO(thaJeztah): cli-docs-tool should already be able to do this, but assumes source-files are not in subdirectories (it looks for `src/docker_command_subcommand.md`) |
| 47 | if err := loadLongDescription(cmd, opts.source); err != nil { |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | c, err := clidocstool.New(clidocstool.Options{ |
| 52 | Root: cmd, |
| 53 | SourceDir: opts.source, |
| 54 | TargetDir: opts.target, |
| 55 | ManHeader: &doc.GenManHeader{ |
| 56 | Title: "DOCKER", |
| 57 | Section: "1", |
| 58 | Source: "Docker Community", |
| 59 | Manual: "Docker User Manuals", |
| 60 | }, |
| 61 | Plugin: false, |
| 62 | }) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | fmt.Println("Manpage source folder:", opts.source) |
| 67 | fmt.Println("Generating man pages into", opts.target) |
| 68 | return c.GenManTree(cmd) |
| 69 | } |
| 70 | |
| 71 | func loadLongDescription(parentCommand *cobra.Command, path string) error { |
| 72 | for _, cmd := range parentCommand.Commands() { |
no test coverage detected