Skip to content

Commit

Permalink
test: add root flags for tests
Browse files Browse the repository at this point in the history
Adds a hidden --help flag (like in docker/cli) and a dummy -H flag

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
  • Loading branch information
dvdksn committed Jul 2, 2024
1 parent 7142e86 commit 7d56538
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 30 deletions.
5 changes: 5 additions & 0 deletions clidocstool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func setup() {
DisableFlagsInUseLine: true,
}

dockerCmd.PersistentFlags().BoolP("help", "h", false, "Print usage")
dockerCmd.PersistentFlags().MarkShorthandDeprecated("help", "please use --help")
dockerCmd.PersistentFlags().Lookup("help").Hidden = true
dockerCmd.Flags().StringP("host", "H", "unix:///var/run/docker.sock", "Daemon socket to connect to")

attachCmd = &cobra.Command{
Use: "attach [OPTIONS] CONTAINER",
Short: "Attach local standard input, output, and error streams to a running container",
Expand Down
4 changes: 0 additions & 4 deletions fixtures/docker-attach.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Attach local standard input, output, and error streams to a running container
\fB--detach-keys\fP=""
Override the key sequence for detaching a container

.PP
\fB-h\fP, \fB--help\fP[=false]
help for attach

.PP
\fB--no-stdin\fP[=false]
Do not attach STDIN
Expand Down
4 changes: 0 additions & 4 deletions fixtures/docker-buildx-build.1
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Start a build
\fB-f\fP, \fB--file\fP=""
Name of the Dockerfile (default: "PATH/Dockerfile")

.PP
\fB-h\fP, \fB--help\fP[=false]
help for build

.PP
\fB--iidfile\fP=""
Write the image ID to the file
Expand Down
4 changes: 0 additions & 4 deletions fixtures/docker-buildx-dial-stdio.1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Proxy current stdio streams to builder instance


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for dial-stdio

.PP
\fB--platform\fP=""
Target platform: this is used for node selection
Expand Down
6 changes: 0 additions & 6 deletions fixtures/docker-buildx-install.1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ docker-buildx-install - Install buildx as a 'docker builder' alias
Install buildx as a 'docker builder' alias


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for install


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--builder\fP=""
Expand Down
6 changes: 0 additions & 6 deletions fixtures/docker-buildx-stop.1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ docker-buildx-stop - Stop builder instance
Stop builder instance


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for stop


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB--builder\fP=""
Expand Down
4 changes: 0 additions & 4 deletions fixtures/docker-buildx.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Extended build capabilities with BuildKit
\fB--builder\fP=""
Override the configured builder instance

.PP
\fB-h\fP, \fB--help\fP[=false]
help for buildx


.SH SEE ALSO
.PP
Expand Down
4 changes: 2 additions & 2 deletions fixtures/docker.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ A self-sufficient runtime for containers

.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for docker
\fB-H\fP, \fB--host\fP="unix:///var/run/docker.sock"
Daemon socket to connect to


.SH SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletions fixtures/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ A self-sufficient runtime for containers
| [`buildx`](buildx.md) | Docker Buildx |


### Options

| Name | Type | Default | Description |
|:---------------|:---------|:------------------------------|:----------------------------|
| `-H`, `--host` | `string` | `unix:///var/run/docker.sock` | Daemon socket to connect to |


<!---MARKER_GEN_END-->

22 changes: 22 additions & 0 deletions fixtures/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ cname:
clink:
- docker_attach.yaml
- docker_buildx.yaml
options:
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: host
shorthand: H
value_type: string
default_value: unix:///var/run/docker.sock
description: Daemon socket to connect to
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down
11 changes: 11 additions & 0 deletions fixtures/docker_attach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
inherited_options:
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down
11 changes: 11 additions & 0 deletions fixtures/docker_buildx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
inherited_options:
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down
10 changes: 10 additions & 0 deletions fixtures/docker_buildx_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ inherited_options:
experimentalcli: false
kubernetes: false
swarm: false
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down
10 changes: 10 additions & 0 deletions fixtures/docker_buildx_dial-stdio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ inherited_options:
experimentalcli: false
kubernetes: false
swarm: false
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down
10 changes: 10 additions & 0 deletions fixtures/docker_buildx_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ inherited_options:
experimentalcli: false
kubernetes: false
swarm: false
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: true
experimental: false
Expand Down
10 changes: 10 additions & 0 deletions fixtures/docker_buildx_stop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ inherited_options:
experimentalcli: false
kubernetes: false
swarm: false
- option: help
value_type: bool
default_value: "false"
description: Print usage
deprecated: false
hidden: true
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
hidden: false
experimental: false
Expand Down

0 comments on commit 7d56538

Please sign in to comment.