Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clidocstool.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"io"
"os"
"strings"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -99,6 +100,13 @@ func copyFile(src string, dst string) error {
}

func getAliases(cmd *cobra.Command) []string {
if a := cmd.Annotations["aliases"]; a != "" {
aliases := strings.Split(a, ",")
for i := 0; i < len(aliases); i++ {
aliases[i] = strings.TrimSpace(aliases[i])
}
return aliases
}
if len(cmd.Aliases) == 0 {
return cmd.Aliases
}
Expand Down
3 changes: 3 additions & 0 deletions clidocstool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func init() {
Aliases: []string{"b"},
Short: "Start a build",
Run: func(cmd *cobra.Command, args []string) {},
Annotations: map[string]string{
"aliases": "docker image build, docker buildx build, docker buildx b, docker build",
},
}
buildxStopCmd = &cobra.Command{
Use: "stop [NAME]",
Expand Down
2 changes: 1 addition & 1 deletion fixtures/buildx_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Start a build

### Aliases

`docker buildx build`, `docker buildx b`
`docker image build`, `docker buildx build`, `docker buildx b`, `docker build`

### Options

Expand Down
2 changes: 1 addition & 1 deletion fixtures/docker_buildx_build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
command: docker buildx build
aliases: docker buildx build, docker buildx b
aliases: docker image build, docker buildx build, docker buildx b, docker build
short: Start a build
long: Start a build
usage: docker buildx build [OPTIONS] PATH | URL | -
Expand Down