Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jun 28, 2022

The default output for Cobra aliases only shows the subcommand as alias, which
is not very intuitive. This patch changes the output to print the full command
as it would be called by the user.

Note that there's still some improvements to be made; due to how aliases must be
set-up in Cobra, aliases at different "levels" are still not shown. So for example,
docker ps --help will not show docker container ps as alias, and vice-versa.
This will require additional changes, and can possibly be resolved using custom
metadata/annotations.

Before this patch:

docker container ls --help

Usage:  docker container ls [OPTIONS]

List containers

Aliases:
  ls, ps, list

After this patch:

docker container ls --help

Usage:  docker container ls [OPTIONS]

List containers

Aliases:
  docker container ls, docker container ps, docker container list

- Description for the changelog

Usage output for command aliases now prints the full name for each alias.

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2022

Codecov Report

Merging #3693 (4dead11) into master (b496125) will increase coverage by 0.00%.
The diff coverage is 90.90%.

@@           Coverage Diff           @@
##           master    #3693   +/-   ##
=======================================
  Coverage   59.01%   59.02%           
=======================================
  Files         289      289           
  Lines       24623    24645   +22     
=======================================
+ Hits        14532    14546   +14     
- Misses       9218     9225    +7     
- Partials      873      874    +1     

The default output for Cobra aliases only shows the subcommand as alias, which
is not very intuitive. This patch changes the output to print the full command
as it would be called by the user.

Note that there's still some improvements to be made; due to how aliases must be
set-up in Cobra, aliases at different "levels" are still not shown. So for example,
`docker ps --help` will not show `docker container ps` as alias, and vice-versa.
This will require additional changes, and can possibly be resolved using custom
metadata/annotations.

Before this patch:

    docker container ls --help

    Usage:  docker container ls [OPTIONS]

    List containers

    Aliases:
      ls, ps, list

After this patch:

    docker container ls --help

    Usage:  docker container ls [OPTIONS]

    List containers

    Aliases:
      docker container ls, docker container ps, docker container list

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the cli_usage_aliases branch from 4dead11 to 2d88c89 Compare June 28, 2022 09:03
@thaJeztah thaJeztah marked this pull request as ready for review June 28, 2022 09:22
@thaJeztah thaJeztah added this to the 22.06.0 milestone Jun 28, 2022
@thaJeztah
Copy link
Member Author

@crazy-max @ndeloof @rumpl PTAL

(follow-up is in #3694, but also want to make some changes to our YAML generator)

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@thaJeztah thaJeztah merged commit 05d288e into docker:master Jun 28, 2022
@thaJeztah thaJeztah deleted the cli_usage_aliases branch June 28, 2022 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants