You've already forked cli-docs-tool
mirror of
https://github.com/docker/cli-docs-tool.git
synced 2025-08-08 10:22:04 +03:00
always disable the addition of [flags] to the usage
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -80,25 +80,6 @@ func (c *Client) GenAllTree() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DisableFlagsInUseLine sets the DisableFlagsInUseLine flag on all
|
||||
// commands within the tree rooted at cmd.
|
||||
func (c *Client) DisableFlagsInUseLine() {
|
||||
visitAll(c.root, func(ccmd *cobra.Command) {
|
||||
// do not add a `[flags]` to the end of the usage line.
|
||||
ccmd.DisableFlagsInUseLine = true
|
||||
})
|
||||
}
|
||||
|
||||
// visitAll traverses all commands from the root.
|
||||
// This is different from the VisitAll of cobra.Command where only parents
|
||||
// are checked.
|
||||
func visitAll(root *cobra.Command, fn func(*cobra.Command)) {
|
||||
for _, cmd := range root.Commands() {
|
||||
visitAll(cmd, fn)
|
||||
}
|
||||
fn(root)
|
||||
}
|
||||
|
||||
func fileExists(f string) bool {
|
||||
info, err := os.Stat(f)
|
||||
if os.IsNotExist(err) {
|
||||
|
@@ -37,6 +37,9 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
|
||||
}
|
||||
}
|
||||
|
||||
// always disable the addition of [flags] to the usage
|
||||
cmd.DisableFlagsInUseLine = true
|
||||
|
||||
// Skip the root command altogether, to prevent generating a useless
|
||||
// md file for plugins.
|
||||
if c.plugin && !cmd.HasParent() {
|
||||
|
@@ -97,6 +97,9 @@ func (c *Client) genYamlTreeCustom(cmd *cobra.Command, filePrepender func(string
|
||||
}
|
||||
}
|
||||
|
||||
// always disable the addition of [flags] to the usage
|
||||
cmd.DisableFlagsInUseLine = true
|
||||
|
||||
// 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
|
||||
|
@@ -63,7 +63,6 @@ func gen(opts *options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.DisableFlagsInUseLine()
|
||||
|
||||
// generate all supported docs formats
|
||||
return c.GenAllTree()
|
||||
|
@@ -2,7 +2,7 @@ command: docker buildx build
|
||||
aliases: b
|
||||
short: Start a build
|
||||
long: Start a build
|
||||
usage: docker buildx build [OPTIONS] PATH | URL | - [flags]
|
||||
usage: docker buildx build [OPTIONS] PATH | URL | -
|
||||
pname: docker buildx
|
||||
plink: docker_buildx.yaml
|
||||
options:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
command: docker buildx stop
|
||||
short: Stop builder instance
|
||||
long: Stop builder instance
|
||||
usage: docker buildx stop [NAME] [flags]
|
||||
usage: docker buildx stop [NAME]
|
||||
pname: docker buildx
|
||||
plink: docker_buildx.yaml
|
||||
inherited_options:
|
||||
|
Reference in New Issue
Block a user