Skip to content

Commit 9cd8f1a

Browse files
committed
feature: fixed parsing of global flags
1 parent 8046ddd commit 9cd8f1a

File tree

8 files changed

+12
-10
lines changed

8 files changed

+12
-10
lines changed

internal/cmd/beta/security-group/create/create.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
4646
}
4747

4848
func configureFlags(cmd *cobra.Command) {
49-
globalflags.Configure(cmd.Flags())
5049
cmd.Flags().String("name", "", "the name of the security group. Must be <= 63 chars")
5150
cmd.Flags().String("description", "", "an optional description of the security group. Must be <= 127 chars")
5251
cmd.Flags().Bool("stateful", false, "create a stateful or a stateless security group")

internal/cmd/beta/security-group/create/create_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ func TestParseInput(t *testing.T) {
188188
t.Run(tt.description, func(t *testing.T) {
189189
p := print.NewPrinter()
190190
cmd := NewCmd(p)
191+
if err := globalflags.Configure(cmd.Flags()); err != nil {
192+
t.Errorf("cannot configure global flags: %v", err)
193+
}
191194

192195
for flag, value := range tt.flagValues {
193196
err := cmd.Flags().Set(flag, value)

internal/cmd/beta/security-group/describe/describe.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
3939
return executeDescribe(cmd, p, args)
4040
},
4141
}
42-
configureFlags(cmd)
4342

4443
return cmd
4544
}
@@ -74,10 +73,6 @@ func executeDescribe(cmd *cobra.Command, p *print.Printer, args []string) error
7473
return nil
7574
}
7675

77-
func configureFlags(cmd *cobra.Command) {
78-
globalflags.Configure(cmd.Flags())
79-
}
80-
8176
func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiGetSecurityGroupRequest {
8277
request := apiClient.GetSecurityGroup(ctx, model.ProjectId, model.SecurityGroupId)
8378
return request

internal/cmd/beta/security-group/describe/describe_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ func TestParseInput(t *testing.T) {
121121
t.Run(tt.description, func(t *testing.T) {
122122
p := print.NewPrinter()
123123
cmd := NewCmd(p)
124-
124+
if err := globalflags.Configure(cmd.Flags()); err != nil {
125+
t.Errorf("cannot configure global flags: %v", err)
126+
}
125127
for flag, value := range tt.flagValues {
126128
err := cmd.Flags().Set(flag, value)
127129
if err != nil {

internal/cmd/beta/security-group/list/list.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
4545
}
4646

4747
func configureFlags(cmd *cobra.Command) {
48-
globalflags.Configure(cmd.Flags())
4948
cmd.Flags().String("labels", "", "a list of labels in the form <key>=<value>")
5049
}
5150

internal/cmd/beta/security-group/list/list_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ func TestParseInput(t *testing.T) {
121121
t.Run(tt.description, func(t *testing.T) {
122122
p := print.NewPrinter()
123123
cmd := NewCmd(p)
124+
if err := globalflags.Configure(cmd.Flags()); err != nil {
125+
t.Errorf("cannot configure global flags: %v", err)
126+
}
124127

125128
for flag, value := range tt.flagValues {
126129
err := cmd.Flags().Set(flag, value)

internal/cmd/beta/security-group/update/update.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
4848
}
4949

5050
func configureFlags(cmd *cobra.Command) {
51-
globalflags.Configure(cmd.Flags())
5251
cmd.Flags().String("name", "", "the name of the security group. Must be <= 63 chars")
5352
cmd.Flags().String("description", "", "an optional description of the security group. Must be <= 127 chars")
5453
cmd.Flags().StringSlice("labels", nil, "a list of labels in the form <key>=<value>")

internal/cmd/beta/security-group/update/update_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ func TestParseInput(t *testing.T) {
226226
t.Run(tt.description, func(t *testing.T) {
227227
p := print.NewPrinter()
228228
cmd := NewCmd(p)
229-
229+
if err := globalflags.Configure(cmd.Flags()); err != nil {
230+
t.Errorf("cannot configure global flags: %v", err)
231+
}
230232
for flag, value := range tt.flagValues {
231233

232234
if err := cmd.Flags().Set(flag, value); err != nil {

0 commit comments

Comments
 (0)