github.com/arduino/arduino-cloud-cli@v0.0.0-20240517070944-e7a449561083/command/ota/cancel.go (about) 1 package ota 2 3 import ( 4 "fmt" 5 6 "github.com/arduino/arduino-cli/cli/feedback" 7 "github.com/arduino/arduino-cloud-cli/config" 8 otaapi "github.com/arduino/arduino-cloud-cli/internal/ota-api" 9 ) 10 11 func CancelOta(otaid string, cred *config.Credentials) error { 12 13 if feedback.GetFormat() == feedback.JSONMini { 14 return fmt.Errorf("jsonmini format is not supported for this command") 15 } 16 17 otapi := otaapi.NewClient(cred) 18 19 if otaid != "" { 20 _, err := otapi.CancelOta(otaid) 21 if err != nil { 22 return err 23 } 24 // No error, get current status 25 res, err := otapi.GetOtaStatusByOtaID(otaid, 1, otaapi.OrderDesc) 26 if err != nil { 27 return err 28 } 29 if res != nil { 30 feedback.PrintResult(res.Ota) 31 } 32 return nil 33 } 34 35 return nil 36 }