Skip to content

Commit eb13b82

Browse files
committed
adds goflagset for apply & cleanup subcommands
1 parent 3e17df7 commit eb13b82

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

internal/cmd/cli/apply.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cli
33
import (
44
"bytes"
55
"errors"
6+
"flag"
67
"fmt"
78
"os"
89

@@ -33,10 +34,15 @@ type readFile func(name string) ([]byte, error)
3334

3435
// NewApply returns a subcommand to create bundles from directories
3536
func NewApply() *cobra.Command {
36-
return command.Command(&Apply{}, cobra.Command{
37+
cmd := command.Command(&Apply{}, cobra.Command{
3738
Use: "apply [flags] BUNDLE_NAME PATH...",
3839
Short: "Create bundles from directories, and output them or apply them on a cluster",
3940
})
41+
42+
fs := flag.NewFlagSet("", flag.ExitOnError)
43+
ctrl.RegisterFlags(fs)
44+
cmd.Flags().AddGoFlagSet(fs)
45+
return cmd
4046
}
4147

4248
type Apply struct {

internal/cmd/cli/cleanup.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"errors"
5+
"flag"
56
"fmt"
67
"math"
78
"strconv"
@@ -32,21 +33,33 @@ func NewCleanUp() *cobra.Command {
3233
}
3334

3435
func NewClusterRegistration() *cobra.Command {
35-
return command.Command(&ClusterRegistration{}, cobra.Command{
36+
cmd := command.Command(&ClusterRegistration{}, cobra.Command{
3637
Use: "clusterregistration [flags]",
3738
Short: "Clean up outdated cluster registrations",
3839
SilenceUsage: true,
3940
SilenceErrors: true,
4041
})
42+
43+
fs := flag.NewFlagSet("", flag.ExitOnError)
44+
zopts.BindFlags(fs)
45+
ctrl.RegisterFlags(fs)
46+
cmd.Flags().AddGoFlagSet(fs)
47+
return cmd
4148
}
4249

4350
func NewGitjob() *cobra.Command {
44-
return command.Command(&Gitjob{}, cobra.Command{
51+
cmd := command.Command(&Gitjob{}, cobra.Command{
4552
Use: "gitjob [flags]",
4653
Short: "Clean up outdated git jobs",
4754
SilenceUsage: true,
4855
SilenceErrors: true,
4956
})
57+
58+
fs := flag.NewFlagSet("", flag.ExitOnError)
59+
zopts.BindFlags(fs)
60+
ctrl.RegisterFlags(fs)
61+
cmd.Flags().AddGoFlagSet(fs)
62+
return cmd
5063
}
5164

5265
type Cleanup struct {

0 commit comments

Comments
 (0)