@@ -6,12 +6,14 @@ import (
66 "strings"
77
88 "github.com/spf13/cobra"
9+ "github.com/stackitcloud/stackit-cli/internal/pkg/args"
910 "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1011 "github.com/stackitcloud/stackit-cli/internal/pkg/examples"
1112 "github.com/stackitcloud/stackit-cli/internal/pkg/flags"
1213 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1314 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1415 "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
16+ "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1517 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
1618)
1719
@@ -20,12 +22,14 @@ type inputModel struct {
2022 Id string
2123}
2224
25+ const argNameGroupId = "groupId"
26+
2327func NewCmd (p * print.Printer ) * cobra.Command {
2428 cmd := & cobra.Command {
2529 Use : "delete" ,
2630 Short : "delete a security group" ,
2731 Long : "delete a security group by its internal id" ,
28- Args : cobra . ExactArgs ( 1 ),
32+ Args : args . SingleArg ( argNameGroupId , utils . ValidateUUID ),
2933 Example : examples .Build (
3034 examples .NewExample (`delete a named group` , `$ stackit beta security-group delete 43ad419a-c68b-4911-87cd-e05752ac1e31` ),
3135 ),
@@ -80,9 +84,18 @@ func parseInput(p *print.Printer, cmd *cobra.Command, args []string) (*inputMode
8084 if globalFlags .ProjectId == "" {
8185 return nil , & errors.ProjectIdError {}
8286 }
87+ if err := cmd .ValidateArgs (args ); err != nil {
88+ return nil , & errors.ArgValidationError {
89+ Arg : argNameGroupId ,
90+ Details : fmt .Sprintf ("arg validation failed: %v" , err ),
91+ }
92+ }
8393
8494 if len (args ) != 1 {
85- return nil ,& errors.ArgValidationError {}
95+ return nil , & errors.ArgValidationError {
96+ Arg : argNameGroupId ,
97+ Details : "wrong number of arguments" ,
98+ }
8699 }
87100
88101 name := flags .FlagToStringValue (p , cmd , "name" )
0 commit comments