knative / client-contrib

Community contributed `kn` plugins.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[kn-admin] Improve the command examples in usage

chaozbj opened this issue · comments

When I read our codes, I found that we put the command examples in cobra.Command.Long fields, like this:

Long: `Set Knative route domain for service

Actually, cobra.Command has the field Example to set the command examples. I think we'd better use this field to describe our command examples. Like the kn command did:
https://github.com/knative/client/blob/3c5ceff655ec4543907a681c300912076fa49e53/pkg/kn/commands/route/list.go#L36

If we use Example field, the output will look like:

☕16:18 ➜ ~/Workspace/Code/github.com/client-contrib/plugins/admin/cmd [master ✘] ./kn-admin domain set --help
Set Knative route domain for service

Usage:
  kn admin domain set [flags]

Examples:

  # To set a default route domain
  kn admin domain set --custom-domain mydomain.com

  # To set a route domain for service having label app=v1
  kn admin domain set --custom-domain mydomain.com --selector app=v1


Flags:
  -d, --custom-domain string   desired custom domain
  -h, --help                   help for set
      --selector strings       domain selector

Global Flags:
      --config string   config file (default is $HOME/.config/kn/plugins/admin.yaml)

@zhanggbj @ZhuangYuZY @lanceliuu @12345lcr How do you think if we use the field Example? Thanks!

/assign
I agree with it and will update this example field to follow kn to keep the same user experience.
I have a chore #40 PR WIP and will cover it. Thanks!

Merged
@chaodaiG could you please help to close it? Thanks!

/close

@chaodaiG: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.