-
Notifications
You must be signed in to change notification settings - Fork 72
/
flagutil.go
44 lines (38 loc) · 1.08 KB
/
flagutil.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package flagutil
import (
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const (
// FlagProvider is a flag representing an OCM provider ID
FlagProvider = "provider"
// FlagRegion is a flag representing an OCM region ID
FlagRegion = "region"
)
type flagSet struct {
flags *pflag.FlagSet
cmd *cobra.Command
localizer localize.Localizer
*flagutil.FlagSet
}
// NewFlagSet returns a new flag set for creating common Kafka-command flags
func NewFlagSet(cmd *cobra.Command, localizer localize.Localizer) *flagSet {
return &flagSet{
cmd: cmd,
flags: cmd.Flags(),
localizer: localizer,
FlagSet: flagutil.NewFlagSet(cmd, localizer),
}
}
// AddInstanceID adds a flag for setting the Kafka instance ID
func (fs *flagSet) AddInstanceID(instanceID *string) {
flagName := "instance-id"
fs.flags.StringVar(
instanceID,
flagName,
"",
flagutil.FlagDescription(fs.localizer, "kafka.common.flag.instanceID.description"),
)
}