Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/api/escape/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,18 @@ func CreateTag(ctx context.Context, name string, color string) (*v3.TagDetail, e
return nil, fmt.Errorf("api error: %w", err)
}
return data, nil
}
}

// DeleteTag deletes a tag
func DeleteTag(ctx context.Context, id string) error {
client, err := newAPIV3Client()
if err != nil {
return fmt.Errorf("unable to init client: %w", err)
}
req := client.TagsAPI.DeleteTag(ctx, id)
_, _, err = req.Execute()
if err != nil {
return fmt.Errorf("unable to delete tag: %w", err)
}
return nil
}
22 changes: 22 additions & 0 deletions pkg/cli/cmd/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,31 @@ Create a new tag with a custom name and color. Use hex color codes without the #
},
}

var tagsDeleteCmd = &cobra.Command{
Use: "delete tag-id",
Aliases: []string{"del", "rm", "remove"},
Args: cobra.ExactArgs(1),
Short: "Delete a tag",
Long: `Delete Tag - Remove tag from organization

Permanently delete a tag from your organization`,
Example: ` # Delete a tag
escape-cli tags delete 00000000-0000-0000-0000-000000000000`,
RunE: func(cmd *cobra.Command, args []string) error {
id := args[0]
err := escape.DeleteTag(cmd.Context(), id)
if err != nil {
return fmt.Errorf("unable to delete tag: %w", err)
}
out.Log("Tag deleted")
return nil
},
}

func init() {
tagsCmd.AddCommand(tagsListCmd)
tagsCmd.AddCommand(tagsCreateCmd)
tagsCmd.AddCommand(tagsDeleteCmd)

tagsCreateCmd.Flags().StringP("name", "n", "", "Name of the tag")
tagsCreateCmd.Flags().StringP("color", "c", "", "Color of the tag")
Expand Down
Loading