/* Copyright © 2023 Laura Kalb */ package cmd import ( "codeberg.org/lauralani/ovh-apikey-manager/app" "log" "os" "strconv" "github.com/spf13/cobra" ) // deleteCmd represents the delete command var deleteCmd = &cobra.Command{ Use: "delete", Short: "Delete API keys", Long: `Delete a single API key by ID`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { client := app.GetOVHClient() id := args[0] _, err := strconv.Atoi(id) if err != nil { log.Printf("Argument must be a valid number\n") os.Exit(1) } err = client.Delete("/me/api/application/"+id, nil) if err != nil { log.Printf("Error deleting application: %q\n", err) os.Exit(1) } log.Printf("Application with id %v was successfully deleted.\n", id) }, } func init() { rootCmd.AddCommand(deleteCmd) }