New 🌊 wave for @helm

Commit 3d3155bb

3d3155bbb440Merged

Dmitriy Zhilyaev <[email protected]> · 2 years ago · 10 files · +4 added · ~6 modified

Description

feat: flags refactoring

Signed-off-by: Dmitriy Zhilyaev [email protected]

Details

Commit
3d3155bbb440
Parent
4d35f319ffef

cmd/helmwave/commands.goaddedView file

1+package main
2+
3+import (
4+ "fmt"
5+ "github.com/helmwave/helmwave/pkg/action"
6+ helmwave "github.com/helmwave/helmwave/pkg/version"
7+ "github.com/urfave/cli/v2"
8+)
9+
10+// commands is a registration list for commands
11+var commands = []*cli.Command{
12+ new(action.Build).Cmd(),
13+ new(action.Diff).Cmd(),
14+ new(action.Up).Cmd(),
15+ new(action.List).Cmd(),
16+ new(action.Rollback).Cmd(),
17+ new(action.Status).Cmd(),
18+ new(action.Down).Cmd(),
19+ new(action.Validate).Cmd(),
20+ new(action.Yml).Cmd(),
21+ new(action.GenSchema).Cmd(),
22+ new(action.Graph).Cmd(),
23+ version(),
24+ completion(),
25+}
26+
27+func version() *cli.Command {
28+ return &cli.Command{
29+ Name: "version",
30+ Aliases: []string{"ver"},
31+ Category: action.Step_,
32+ Usage: "show shorts version",
33+ Action: func(c *cli.Context) error {
34+ fmt.Println(helmwave.Version) //nolint:forbidigo // we need to use fmt.Println here
35+
36+ return nil
37+ },
38+ }
39+}
40+
41+// CommandNotFoundError is return when CLI command is not found.
42+type CommandNotFoundError struct {
43+ Command string
44+}
45+
46+func (e CommandNotFoundError) Error() string {
47+ return fmt.Sprintf("👻 Command %q not found", e.Command)
48+}
49+
50+func command404(_ *cli.Context, s string) {
51+ err := CommandNotFoundError{
52+ Command: s,
53+ }
54+ panic(err)
55+}