mirror of https://github.com/docker/cli.git
docs/yaml: add TODO for conditionally skipping root command
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c509ef7104
commit
b86f5135f6
|
@ -73,9 +73,23 @@ func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !cmd.HasParent() {
|
|
||||||
return nil
|
// TODO: conditionally skip the root command (for plugins)
|
||||||
}
|
//
|
||||||
|
// The "root" command used in the generator is just a "stub", and only has a
|
||||||
|
// list of subcommands, but not (e.g.) global options/flags. We should fix
|
||||||
|
// that, so that the YAML file for the docker "root" command contains the
|
||||||
|
// global flags.
|
||||||
|
//
|
||||||
|
// If we're using this code to generate YAML docs for a plugin, the root-
|
||||||
|
// command is even less useful; in that case, the root command represents
|
||||||
|
// the "docker" command, and is a "dummy" with no flags, and only a single
|
||||||
|
// subcommand (the plugin's top command). For plugins, we should skip the
|
||||||
|
// root command altogether, to prevent generating a useless YAML file.
|
||||||
|
// if !cmd.HasParent() {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
|
||||||
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml"
|
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml"
|
||||||
filename := filepath.Join(dir, basename)
|
filename := filepath.Join(dir, basename)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
|
|
Loading…
Reference in New Issue