Skip to content

Commit

Permalink
Patch command names in examples
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Zarytovsky <[email protected]>
  • Loading branch information
asviel committed Apr 11, 2024
1 parent 5b8f8be commit 645bb4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions cmd/werf.go → cmd/delivery.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"strings"

"github.com/samber/lo"
"github.com/spf13/cobra"

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

werfRootCmd.Use = "d"
werfRootCmd.Aliases = []string{"delivery"}
werfRootCmd = ReplaceCommandName("werf", "d8 d", werfRootCmd)
werfRootCmd.Short = strings.Replace(werfRootCmd.Short, "werf", "d8 d", 1)
werfRootCmd.Long = strings.Replace(werfRootCmd.Long, "werf", "d8 d", 1)

removeKubectlCmd(werfRootCmd)

rootCmd.AddCommand(werfRootCmd)
Expand Down
11 changes: 0 additions & 11 deletions cmd/kubectl.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
package cmd

import (
"strings"

"github.com/spf13/cobra"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
kubecmd "k8s.io/kubectl/pkg/cmd"
)

func ReplaceCommandName(from, to string, c *cobra.Command) *cobra.Command {
c.Example = strings.Replace(c.Example, from, to, -1)
c.Long = strings.Replace(c.Long, from, to, -1)
for _, sub := range c.Commands() {
ReplaceCommandName(from, to, sub)
}
return c
}

func init() {
kubectlCmd := kubecmd.NewDefaultKubectlCommand()
kubectlCmd.Use = "k"
Expand Down
11 changes: 11 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"math/rand"
"os"
"strings"
"time"

"github.com/sirupsen/logrus"
Expand All @@ -21,6 +22,16 @@ import (
"github.com/werf/werf/pkg/process_exterminator"
)

func ReplaceCommandName(from, to string, c *cobra.Command) *cobra.Command {
c.Example = strings.Replace(c.Example, from, to, -1)
// Need some investigation about links
// c.Long = strings.Replace(c.Long, from, to, -1)
for _, sub := range c.Commands() {
ReplaceCommandName(from, to, sub)
}
return c
}

var Version string

var rootCmd = &cobra.Command{
Expand Down

0 comments on commit 645bb4c

Please sign in to comment.