Skip to content

Commit 8ced391

Browse files
committed
display flag type and default value in dedicated columns
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 77df2af commit 8ced391

File tree

4 files changed

+44
-37
lines changed

4 files changed

+44
-37
lines changed

clidocstool_md.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
179179

180180
if cmd.Flags().HasAvailableFlags() {
181181
fmt.Fprint(b, "### Options\n\n")
182-
fmt.Fprint(b, "| Name | Description |\n")
183-
fmt.Fprint(b, "| --- | --- |\n")
182+
fmt.Fprint(b, "| Name | Type | Default | Description |\n")
183+
fmt.Fprint(b, "| --- | --- | --- | --- |\n")
184184

185185
cmd.Flags().VisitAll(func(f *pflag.Flag) {
186186
if f.Hidden {
@@ -193,19 +193,26 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
193193
name = mdMakeLink(name, f.Name, f, isLink)
194194
fmt.Fprintf(b, "%s, ", name)
195195
}
196-
name := "`--" + f.Name
196+
name := "`--" + f.Name + "`"
197+
name = mdMakeLink(name, f.Name, f, isLink)
198+
199+
var ftype string
197200
if f.Value.Type() != "bool" {
198-
name += " " + f.Value.Type()
201+
ftype = "`" + f.Value.Type() + "`"
199202
}
200-
name += "`"
201-
name = mdMakeLink(name, f.Name, f, isLink)
203+
204+
var defval string
205+
if f.DefValue != "" && (f.Value.Type() != "bool" && f.DefValue != "true") && f.DefValue != "[]" {
206+
defval = "`" + f.DefValue + "`"
207+
}
208+
202209
usage := f.Usage
203210
if cd, ok := f.Annotations[annotation.CodeDelimiter]; ok {
204211
usage = strings.ReplaceAll(usage, cd[0], "`")
205212
} else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
206213
usage = strings.ReplaceAll(usage, cd, "`")
207214
}
208-
fmt.Fprintf(b, "%s | %s |\n", mdEscapePipe(name), mdEscapePipe(usage))
215+
fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdEscapePipe(usage))
209216
})
210217
fmt.Fprintln(b, "")
211218
}

fixtures/buildx.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Extended build capabilities with BuildKit
1313

1414
### Options
1515

16-
| Name | Description |
17-
| --- | --- |
18-
| `--builder string` | Override the configured builder instance |
16+
| Name | Type | Default | Description |
17+
| --- | --- | --- | --- |
18+
| `--builder` | `string` | | Override the configured builder instance |
1919

2020

2121
<!---MARKER_GEN_END-->

fixtures/buildx_build.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@ Start a build
99

1010
### Options
1111

12-
| Name | Description |
13-
| --- | --- |
14-
| [`--add-host stringSlice`](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) | Add a custom host-to-IP mapping (format: `host:ip`) |
15-
| `--allow stringSlice` | Allow extra privileged entitlement (e.g., `network.host`, `security.insecure`) |
16-
| [`--build-arg stringArray`](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) | Set build-time variables |
17-
| `--builder string` | Override the configured builder instance |
18-
| `--cache-from stringArray` | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
19-
| `--cache-to stringArray` | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
20-
| [`--cgroup-parent string`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | Optional parent cgroup for the container |
21-
| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file string`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | Name of the Dockerfile (default: `PATH/Dockerfile`) |
22-
| `--iidfile string` | Write the image ID to the file |
23-
| `--label stringArray` | Set metadata for an image |
24-
| `--load` | Shorthand for `--output=type=docker` |
25-
| `--network string` | Set the networking mode for the `RUN` instructions during build |
26-
| `-o`, `--output stringArray` | Output destination (format: `type=local,dest=path`) |
27-
| `--platform stringArray` | Set target platform for build |
28-
| `--push` | Shorthand for `--output=type=registry` |
29-
| `-q`, `--quiet` | Suppress the build output and print image ID on success |
30-
| `--secret stringArray` | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
31-
| `--shm-size string` | Size of `/dev/shm` |
32-
| `--ssh stringArray` | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
33-
| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag stringArray`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | Name and optionally a tag (format: `name:tag`) |
34-
| [`--target string`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | Set the target build stage to build. |
35-
| `--ulimit string` | Ulimit options |
12+
| Name | Type | Default | Description |
13+
| --- | --- | --- | --- |
14+
| [`--add-host`](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) | `stringSlice` | | Add a custom host-to-IP mapping (format: `host:ip`) |
15+
| `--allow` | `stringSlice` | | Allow extra privileged entitlement (e.g., `network.host`, `security.insecure`) |
16+
| [`--build-arg`](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) | `stringArray` | | Set build-time variables |
17+
| `--builder` | `string` | | Override the configured builder instance |
18+
| `--cache-from` | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
19+
| `--cache-to` | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
20+
| [`--cgroup-parent`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | `string` | | Optional parent cgroup for the container |
21+
| [`-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`) |
22+
| `--iidfile` | `string` | | Write the image ID to the file |
23+
| `--label` | `stringArray` | | Set metadata for an image |
24+
| `--load` | | | Shorthand for `--output=type=docker` |
25+
| `--network` | `string` | `default` | Set the networking mode for the `RUN` instructions during build |
26+
| `-o`, `--output` | `stringArray` | | Output destination (format: `type=local,dest=path`) |
27+
| `--platform` | `stringArray` | | Set target platform for build |
28+
| `--push` | | | Shorthand for `--output=type=registry` |
29+
| `-q`, `--quiet` | | | Suppress the build output and print image ID on success |
30+
| `--secret` | `stringArray` | | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
31+
| `--shm-size` | `string` | | Size of `/dev/shm` |
32+
| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
33+
| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | `stringArray` | | Name and optionally a tag (format: `name:tag`) |
34+
| [`--target`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | `string` | | Set the target build stage to build. |
35+
| `--ulimit` | `string` | | Ulimit options |
3636

3737

3838
<!---MARKER_GEN_END-->

fixtures/buildx_stop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Stop builder instance
55

66
### Options
77

8-
| Name | Description |
9-
| --- | --- |
10-
| `--builder string` | Override the configured builder instance |
8+
| Name | Type | Default | Description |
9+
| --- | --- | --- | --- |
10+
| `--builder` | `string` | | Override the configured builder instance |
1111

1212

1313
<!---MARKER_GEN_END-->

0 commit comments

Comments
 (0)