DockerCLI/cli
Sebastiaan van Stijn 80b1285fec cli: use custom annotation for aliases
Cobra allows for aliases to be defined for a command, but only allows these
to be defined at the same level (for example, `docker image ls` as alias for
`docker image list`). Our CLI has some commands that are available both as a
top-level shorthand as well as `docker <object> <verb>` subcommands. For example,
`docker ps` is a shorthand for `docker container ps` / `docker container ls`.

This patch introduces a custom "aliases" annotation that can be used to print
all available aliases for a command. While this requires these aliases to be
defined manually, in practice the list of aliases rarely changes, so maintenance
should be minimal.

As a convention, we could consider the first command in this list to be the
canonical command, so that we can use this information to add redirects in
our documentation in future.

Before this patch:

    docker images --help

    Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

    List images

    Options:
      -a, --all             Show all images (default hides intermediate images)
      ...

With this patch:

    docker images --help

    Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

    List images

    Aliases:
      docker image ls, docker image list, docker images

    Options:
      -a, --all             Show all images (default hides intermediate images)
      ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-28 17:32:09 +02:00
..
command cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
compose Added Swarm Job support to Stack Deploy 2022-05-17 22:30:22 +02:00
config TestSaveFileToDirs: use filepath.Join() 2022-05-04 19:49:10 +02:00
connhelper gofmt with go1.17 2022-03-26 20:21:00 +01:00
context Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
debug updated vendoring 2017-09-01 19:41:06 -04:00
flags use client consts for environment variable names 2022-03-30 17:42:20 +02:00
manifest remove unneeded "digest" alias for "go-digest" 2022-03-04 14:45:37 +01:00
registry/client cli/registry/client: remove unused IsNotFound(), and slight refactor 2022-03-30 20:00:36 +02:00
streams update docker, replace github.com/docker/pkg/term, github.com/docker/pkg/mount 2020-04-22 17:16:13 +02:00
trust remove unneeded "digest" alias for "go-digest" 2022-03-04 14:45:37 +01:00
version Move versioning variables to a separate package. 2019-01-29 11:26:40 +00:00
winresources Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
cobra.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
cobra_test.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
error.go Import docker/docker/cli 2017-04-17 17:40:59 -04:00
required.go Disable unparam linter: cli/required.go:102:16: `pluralize` - `word` always receives `"argument"` (unparam) 2019-10-31 19:22:22 +01:00
required_test.go cli: remove deprecated io/ioutil 2022-02-25 15:42:19 +01:00