diff --git a/clidocstool_md.go b/clidocstool_md.go index 1dee58c..0b08d9e 100644 --- a/clidocstool_md.go +++ b/clidocstool_md.go @@ -241,7 +241,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) { name += mdMakeLink("`--"+f.Name+"`", f.Name, f, isLink) var ftype string - if f.Value.Type() != "bool" { + if f.Value.Type() != "bool" || (f.Value.Type() == "bool" && f.DefValue == "true") { ftype = "`" + f.Value.Type() + "`" } @@ -253,7 +253,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) { } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok { defval = strings.ReplaceAll(defval, cd, "`") } - } else if f.DefValue != "" && (f.Value.Type() != "bool" && f.DefValue != "true") && f.DefValue != "[]" { + } else if f.DefValue != "" && ((f.Value.Type() != "bool" && f.DefValue != "true") || (f.Value.Type() == "bool" && f.DefValue == "true")) && f.DefValue != "[]" { defval = "`" + f.DefValue + "`" } diff --git a/clidocstool_test.go b/clidocstool_test.go index 7b640d8..2c37ef9 100644 --- a/clidocstool_test.go +++ b/clidocstool_test.go @@ -137,6 +137,8 @@ format: "default|[=|[,]]"`) buildxBuildFlags.StringVar(&ignore, "ulimit", "", "Ulimit options") + buildxBuildFlags.BoolVar(&ignoreBool, "detach", true, "Dummy flag that tests boolean flags with true as default") + // hidden flags buildxBuildFlags.BoolVar(&ignoreBool, "compress", false, "Compress the build context using gzip") buildxBuildFlags.MarkHidden("compress") diff --git a/fixtures/buildx_build.md b/fixtures/buildx_build.md index 742f010..c8a9f73 100644 --- a/fixtures/buildx_build.md +++ b/fixtures/buildx_build.md @@ -18,6 +18,7 @@ Start a build | `--cache-from` | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) | | `--cache-to` | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) | | [`--cgroup-parent`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | `string` | | Optional parent cgroup for the container | +| `--detach` | `bool` | `true` | Dummy flag that tests boolean flags with true as default | | [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) | | `--iidfile` | `string` | | Write the image ID to the file | | `--label` | `stringArray` | | Set metadata for an image | diff --git a/fixtures/docker_buildx_build.yaml b/fixtures/docker_buildx_build.yaml index bc08c65..803f756 100644 --- a/fixtures/docker_buildx_build.yaml +++ b/fixtures/docker_buildx_build.yaml @@ -130,6 +130,16 @@ options: experimentalcli: false kubernetes: false swarm: false + - option: detach + value_type: bool + default_value: "true" + description: Dummy flag that tests boolean flags with true as default + deprecated: false + hidden: false + experimental: false + experimentalcli: false + kubernetes: false + swarm: false - option: file shorthand: f value_type: string