File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "strings"
5
+
4
6
"github.com/spf13/cobra"
5
7
cliflag "k8s.io/component-base/cli/flag"
6
8
"k8s.io/component-base/logs"
7
9
kubecmd "k8s.io/kubectl/pkg/cmd"
8
10
)
9
11
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
+
10
21
func init () {
11
22
kubectlCmd := kubecmd .NewDefaultKubectlCommand ()
12
23
kubectlCmd .Use = "k"
13
24
kubectlCmd .Aliases = []string {"kubectl" }
25
+ kubectlCmd = ReplaceCommandName ("kubectl" , "d8 k" , kubectlCmd )
14
26
15
27
// Based on https://github.com/kubernetes/kubernetes/blob/v1.29.3/staging/src/k8s.io/component-base/cli/run.go#L88
16
28
You can’t perform that action at this time.
0 commit comments