Skip to content

Commit 5b8f8be

Browse files
committed
[kubectl] Adjust d8 k examples and descriptions
Signed-off-by: Yan Zarytovsky <[email protected]>
1 parent 3bc6d1a commit 5b8f8be

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cmd/kubectl.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
package cmd
22

33
import (
4+
"strings"
5+
46
"github.com/spf13/cobra"
57
cliflag "k8s.io/component-base/cli/flag"
68
"k8s.io/component-base/logs"
79
kubecmd "k8s.io/kubectl/pkg/cmd"
810
)
911

12+
func ReplaceCommandName(from, to string, c *cobra.Command) *cobra.Command {
13+
c.Example = strings.Replace(c.Example, from, to, -1)
14+
c.Long = strings.Replace(c.Long, from, to, -1)
15+
for _, sub := range c.Commands() {
16+
ReplaceCommandName(from, to, sub)
17+
}
18+
return c
19+
}
20+
1021
func init() {
1122
kubectlCmd := kubecmd.NewDefaultKubectlCommand()
1223
kubectlCmd.Use = "k"
1324
kubectlCmd.Aliases = []string{"kubectl"}
25+
kubectlCmd = ReplaceCommandName("kubectl", "d8 k", kubectlCmd)
1426

1527
// Based on https://github.com/kubernetes/kubernetes/blob/v1.29.3/staging/src/k8s.io/component-base/cli/run.go#L88
1628

0 commit comments

Comments
 (0)