New ๐ŸŒŠ wave for @helm

Commit 105e6e66

105e6e667200Merged

Dmitrii Zhiliaev <[email protected]> ยท 1 year ago ยท 1 file ยท ~1 modified

Description

feat: completions as subcommands

Details

Commit
105e6e667200
Parent
6b7533856d8d

cmd/helmwave/completion.gomodifiedView file

@@ -3,7 +3,6 @@
33 import (
44 "errors"
55 "fmt"
6-
76 "github.com/helmwave/helmwave/pkg/action"
87 "github.com/urfave/cli/v2"
98 )
@@ -97,31 +96,41 @@
9796 Category: action.Step_,
9897 Usage: "generate completion script",
9998 Description: `
100- echo "source <(helmwave completion bash)" >> ~/.bashrc
101- echo "source <(helmwave completion zsh)" >> ~/.zshrc"
102- helmwave completion fish > ~/.config/fish/functions/helmwave.fish
99+ echo "source <(helmwave completion bash)" >> ~/.bashrc
100+ echo "source <(helmwave completion zsh)" >> ~/.zshrc
101+ helmwave completion fish > ~/.config/fish/functions/helmwave.fish
103102 `,
104- Action: func(c *cli.Context) error {
105- if c.Args().Len() == 0 {
106- return ErrNotChose
107- }
108-
109- switch c.Args().First() {
110- case "bash":
111- fmt.Print(bash) //nolint:forbidigo
103+ Subcommands: []*cli.Command{
104+ {
105+ Name: "bash",
106+ Category: action.Step_,
107+ Usage: "generate bash completion script",
108+ Action: func(c *cli.Context) error {
109+ fmt.Print(bash)
112110
113- return nil
114- case "zsh":
115- fmt.Print(zsh) //nolint:forbidigo
111+ return nil
112+ },
113+ },
114+ {
115+ Name: "zsh",
116+ Category: action.Step_,
117+ Usage: "generate zsh completion script",
118+ Action: func(c *cli.Context) error {
119+ fmt.Print(zsh)
116120
117- return nil
118- case "fish":
119- fmt.Print(fish) //nolint:forbidigo
121+ return nil
122+ },
123+ },
124+ {
125+ Name: "fish",
126+ Category: action.Step_,
127+ Usage: "generate fish completion script",
128+ Action: func(c *cli.Context) error {
129+ fmt.Print(fish)
120130
121- return nil
122- default:
123- return ErrWrongShell
124- }
131+ return nil
132+ },
133+ },
125134 },
126135 }
127136 }