Skip to content

Commit 9cb2d88

Browse files
author
Josh Newman
committed
add multi delete via params
1 parent 34aa0d4 commit 9cb2d88

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/rm.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
var rmCmd = &cobra.Command{
16-
Use: "rm <path>",
16+
Use: "rm <path(s)>",
1717
Short: "Remove parameter(s) by path",
1818
Args: func(cmd *cobra.Command, args []string) error {
1919
if len(args) == 0 {
@@ -68,22 +68,30 @@ func runRmCmd(cmd *cobra.Command, args []string) {
6868
os.Exit(0)
6969
}
7070
} else {
71-
names = append(names, &path)
71+
for _, arg := range args {
72+
// declare in loop for pointer to not be repeated
73+
str := arg
74+
names = append(names, &str)
75+
}
7276
}
7377

7478
chunks := getStringChunks(names, 10)
7579

80+
num := 0
81+
7682
for _, chunk := range chunks {
77-
_, err := client.DeleteParameters(&ssm.DeleteParametersInput{
83+
res, err := client.DeleteParameters(&ssm.DeleteParametersInput{
7884
Names: chunk,
7985
})
8086

8187
if err != nil {
8288
panic(err)
8389
}
90+
91+
num += len(res.DeletedParameters)
8492
}
8593

86-
fmt.Println(text.FgGreen.Sprintf("Deleted %d parameters successfully", len(names)))
94+
fmt.Println(text.FgGreen.Sprintf("Deleted %d parameters successfully", num))
8795
}
8896

8997
func init() {

0 commit comments

Comments
 (0)