Skip to content

Commit

Permalink
Use LoadSketch in runUploadCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Sep 6, 2023
1 parent 24acaa8 commit a2fc690
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/cli/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"strings"

"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/commands"
sk "github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/commands/upload"
Expand Down Expand Up @@ -90,7 +89,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
feedback.Warning(msg)
}

sk, err := sketch.New(sketchPath)
sketch, err := sk.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()})
if err != nil && importDir == "" && importFile == "" {
feedback.Fatal(tr("Error during Upload: %v", err), feedback.ErrGeneric)
}
Expand All @@ -99,7 +98,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
var profile *rpc.Profile

if profileArg.Get() == "" {
inst, profile = instance.CreateAndInitWithProfile(sk.Project.DefaultProfile, sketchPath)
inst, profile = instance.CreateAndInitWithProfile(sketch.GetDefaultProfile().GetName(), sketchPath)
} else {
inst, profile = instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath)
}
Expand All @@ -108,8 +107,9 @@ func runUploadCommand(command *cobra.Command, args []string) {
fqbnArg.Set(profile.GetFqbn())
}

defaultFQBN := sk.GetDefaultFQBN()
defaultAddress, defaultProtocol := sk.GetDefaultPortAddressAndProtocol()
defaultFQBN := sketch.GetDefaultFqbn()
defaultAddress := sketch.GetDefaultPort()
defaultProtocol := sketch.GetDefaultProtocol()
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, inst, defaultFQBN, defaultAddress, defaultProtocol)

userFieldRes, err := upload.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
Expand Down

0 comments on commit a2fc690

Please sign in to comment.