DockerCLI/cli/command/image
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
..
build gofmt with go1.17 2022-03-26 20:21:00 +01:00
testdata vendor: github.com/docker/docker v20.10.3-0.20220309172631-83b51522df43 2022-03-09 18:45:37 +01:00
build.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
build_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
client_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
cmd.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
formatter_history.go formatter package heavy refactoring 2018-10-23 17:05:44 +02:00
formatter_history_test.go formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
history.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
history_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
import.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
import_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
inspect.go Output compact JSON by default for --format=json 2022-03-15 15:42:35 +01:00
inspect_test.go vendor: github.com/docker/docker v20.10.3-0.20220309172631-83b51522df43 2022-03-09 18:45:37 +01:00
list.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
list_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
load.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
load_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
prune.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
prune_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
pull.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
pull_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
push.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
push_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
remove.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
remove_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
save.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
save_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
tag.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
tag_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00
trust.go lint: update some nolint comments: 2022-05-13 20:50:19 +02:00
trust_test.go cli/command/image: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:55 +01:00