SIGN IN SIGN UP
spf13 / cobra UNCLAIMED

A Commander for modern Go CLI interactions

0 0 139 Go

Fix --version help and output for plugins (#2180)

* Fix --version help with CommandDisplayNameAnnotation

When setting Command.Version, a --version option is added. The help
message for the --version command did not consider the command display
name:

    Flags:
      -h, --help      help for kubectl plugin
      -v, --version   version for kubectl-plugin

With this change the help test is consistent with other flags:

    Flags:
      -h, --help      help for kubectl plugin
      -v, --version   version for kubectl plugin

* Make command DisplayName() public

This allows using the display name in templates or other code that want
to use the same value.

* Use display name in version template

The version template used `{{.Name}}` but for plugins you want to use
`{{.DisplayName}}` to be consistent with other help output.

With this change will show:

    $ kubectl plugin --version
    kubectl plugin version 1.0.0
N
Nir Soffer committed
5bef9d8d87ad1a1c73e74361bad9e38b3469a58e
Parent: ff7c561
Committed by GitHub <noreply@github.com> on 10/12/2024, 4:08:27 PM