-
Notifications
You must be signed in to change notification settings - Fork 18
/
deletetags.go
39 lines (31 loc) · 900 Bytes
/
deletetags.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
package deletetags
import (
"fmt"
"github.com/spf13/cobra"
"github.com/sagan/ptool/client"
"github.com/sagan/ptool/cmd"
)
var command = &cobra.Command{
Use: "deletetags {client} {tags}...",
Aliases: []string{"deltags"},
Annotations: map[string]string{"cobra-prompt-dynamic-suggestions": "deletetags"},
Short: "Delete tags from client.",
Long: `Delete tags from client.`,
Args: cobra.MatchAll(cobra.MinimumNArgs(2), cobra.OnlyValidArgs),
RunE: deletetags,
}
func init() {
cmd.RootCmd.AddCommand(command)
}
func deletetags(cmd *cobra.Command, args []string) error {
clientInstance, err := client.CreateClient(args[0])
if err != nil {
return fmt.Errorf("failed to create client: %v", err)
}
tags := args[1:]
err = clientInstance.DeleteTags(tags...)
if err != nil {
return fmt.Errorf("failed to delete tags: %v", err)
}
return nil
}