Skip to content

Commit 58ec5ef

Browse files
committed
Adapt to format-output changes
1 parent b86b4c6 commit 58ec5ef

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

cli/cli.go

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/arduino/arduino-cli/cli/feedback"
1111
"github.com/arduino/iot-cloud-cli/cli/config"
1212
"github.com/arduino/iot-cloud-cli/cli/device"
13+
"github.com/arduino/iot-cloud-cli/cli/ota"
1314
"github.com/arduino/iot-cloud-cli/cli/thing"
1415
"github.com/sirupsen/logrus"
1516
"github.com/spf13/cobra"
@@ -31,6 +32,7 @@ func Execute() {
3132
cli.AddCommand(config.NewCommand())
3233
cli.AddCommand(device.NewCommand())
3334
cli.AddCommand(thing.NewCommand())
35+
cli.AddCommand(ota.NewCommand())
3436

3537
cli.PersistentFlags().BoolVarP(&cliFlags.verbose, "verbose", "v", false, "Print the logs on the standard output.")
3638
cli.PersistentFlags().StringVar(&cliFlags.outputFormat, "format", "text", "The output format, can be {text|json}.")

cli/ota/upload.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package ota
22

33
import (
4-
"fmt"
4+
"os"
55

6+
"github.com/arduino/arduino-cli/cli/errorcodes"
7+
"github.com/arduino/arduino-cli/cli/feedback"
68
"github.com/arduino/iot-cloud-cli/command/ota"
9+
"github.com/sirupsen/logrus"
710
"github.com/spf13/cobra"
811
)
912

@@ -17,7 +20,7 @@ func initUploadCommand() *cobra.Command {
1720
Use: "upload",
1821
Short: "OTA upload",
1922
Long: "OTA upload on a device of Arduino IoT Cloud",
20-
RunE: runUploadCommand,
23+
Run: runUploadCommand,
2124
}
2225

2326
uploadCommand.Flags().StringVarP(&uploadFlags.deviceID, "device-id", "d", "", "Device ID")
@@ -28,18 +31,18 @@ func initUploadCommand() *cobra.Command {
2831
return uploadCommand
2932
}
3033

31-
func runUploadCommand(cmd *cobra.Command, args []string) error {
32-
fmt.Printf("Uploading binary %s to device %s\n", uploadFlags.file, uploadFlags.deviceID)
34+
func runUploadCommand(cmd *cobra.Command, args []string) {
35+
logrus.Infof("Uploading binary %s to device %s", uploadFlags.file, uploadFlags.deviceID)
3336

3437
params := &ota.UploadParams{
3538
DeviceID: uploadFlags.deviceID,
3639
File: uploadFlags.file,
3740
}
3841
err := ota.Upload(params)
3942
if err != nil {
40-
return err
43+
feedback.Errorf("Error during ota upload: %v", err)
44+
os.Exit(errorcodes.ErrGeneric)
4145
}
4246

43-
fmt.Println("Upload successfully started")
44-
return nil
47+
logrus.Info("Upload successfully started")
4548
}

0 commit comments

Comments
 (0)