Files
pushbits-cli/internal/application/delete.go
2023-04-01 16:40:57 +02:00

36 lines
665 B
Go

package application
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/pushbits/cli/internal/api"
"github.com/pushbits/cli/internal/options"
"github.com/pushbits/cli/internal/ui"
)
const (
deleteEndpoint = "/application/%d"
)
type deleteCommand struct {
options.AuthOptions
ID uint `arg:"" help:"The ID of the application"`
}
func (c *deleteCommand) Run(_ *options.Options) error {
password := ui.GetCurrentPassword(c.Username)
populatedEndpoint := fmt.Sprintf(deleteEndpoint, c.ID)
resp, err := api.Delete(c.URL, populatedEndpoint, c.Proxy, c.Username, password)
if err != nil {
log.Fatal(err)
}
ui.PrintJSON(resp)
return nil
}