Skip to content

Commit 645bb4c

Browse files
committed
Patch command names in examples
Signed-off-by: Yan Zarytovsky <[email protected]>
1 parent 5b8f8be commit 645bb4c

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

cmd/werf.go renamed to cmd/delivery.go

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

33
import (
4+
"strings"
5+
46
"github.com/samber/lo"
57
"github.com/spf13/cobra"
68

@@ -19,6 +21,10 @@ func init() {
1921

2022
werfRootCmd.Use = "d"
2123
werfRootCmd.Aliases = []string{"delivery"}
24+
werfRootCmd = ReplaceCommandName("werf", "d8 d", werfRootCmd)
25+
werfRootCmd.Short = strings.Replace(werfRootCmd.Short, "werf", "d8 d", 1)
26+
werfRootCmd.Long = strings.Replace(werfRootCmd.Long, "werf", "d8 d", 1)
27+
2228
removeKubectlCmd(werfRootCmd)
2329

2430
rootCmd.AddCommand(werfRootCmd)

cmd/kubectl.go

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

33
import (
4-
"strings"
5-
64
"github.com/spf13/cobra"
75
cliflag "k8s.io/component-base/cli/flag"
86
"k8s.io/component-base/logs"
97
kubecmd "k8s.io/kubectl/pkg/cmd"
108
)
119

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-
2110
func init() {
2211
kubectlCmd := kubecmd.NewDefaultKubectlCommand()
2312
kubectlCmd.Use = "k"

cmd/root.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"math/rand"
88
"os"
9+
"strings"
910
"time"
1011

1112
"github.com/sirupsen/logrus"
@@ -21,6 +22,16 @@ import (
2122
"github.com/werf/werf/pkg/process_exterminator"
2223
)
2324

25+
func ReplaceCommandName(from, to string, c *cobra.Command) *cobra.Command {
26+
c.Example = strings.Replace(c.Example, from, to, -1)
27+
// Need some investigation about links
28+
// c.Long = strings.Replace(c.Long, from, to, -1)
29+
for _, sub := range c.Commands() {
30+
ReplaceCommandName(from, to, sub)
31+
}
32+
return c
33+
}
34+
2435
var Version string
2536

2637
var rootCmd = &cobra.Command{

0 commit comments

Comments
 (0)