knative / client-contrib

Community contributed `kn` plugins.
Apache License 2.0
10 stars 23 forks source link

[kn-admin] Improve the command examples in usage #43

Closed chaozbj closed 4 years ago

chaozbj commented 4 years ago

When I read our codes, I found that we put the command examples in cobra.Command.Long fields, like this: https://github.com/knative/client-contrib/blob/f207c1f9a74266bebeb5a2a32f2a51cf8f9cd87f/plugins/admin/pkg/command/domain/set.go#L38

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!

zhanggbj commented 4 years ago

/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!

zhanggbj commented 4 years ago

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

chaodaiG commented 4 years ago

/close

knative-prow-robot commented 4 years ago

@chaodaiG: Closing this issue.

In response to [this](https://github.com/knative/client-contrib/issues/43#issuecomment-652998222): >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.