Skip to content

Commit bc49faf

Browse files
Add support for default profiles to upload command
1 parent b3b36c6 commit bc49faf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Diff for: internal/cli/upload/upload.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,25 @@ func runUploadCommand(command *cobra.Command, args []string) {
9595
feedback.Fatal(tr("Error during Upload: %v", err), feedback.ErrGeneric)
9696
}
9797

98-
instance, profile := instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath)
98+
var inst *rpc.Instance
99+
var profile *rpc.Profile
100+
101+
if profileArg.Get() == "" {
102+
inst, profile = instance.CreateAndInitWithProfile(sk.Project.DefaultProfile, sketchPath)
103+
} else {
104+
inst, profile = instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath)
105+
}
106+
99107
if fqbnArg.String() == "" {
100108
fqbnArg.Set(profile.GetFqbn())
101109
}
102110

103111
defaultFQBN := sk.GetDefaultFQBN()
104112
defaultAddress, defaultProtocol := sk.GetDefaultPortAddressAndProtocol()
105-
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, instance, defaultFQBN, defaultAddress, defaultProtocol)
113+
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, inst, defaultFQBN, defaultAddress, defaultProtocol)
106114

107115
userFieldRes, err := upload.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
108-
Instance: instance,
116+
Instance: inst,
109117
Fqbn: fqbn,
110118
Protocol: port.Protocol,
111119
})
@@ -122,7 +130,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
122130
}
123131

124132
// FIXME: Here we must not access package manager...
125-
pme, release := commands.GetPackageManagerExplorer(&rpc.UploadRequest{Instance: instance})
133+
pme, release := commands.GetPackageManagerExplorer(&rpc.UploadRequest{Instance: inst})
126134
platform := pme.FindPlatform(&packagemanager.PlatformReference{
127135
Package: split[0],
128136
PlatformArchitecture: split[1],
@@ -156,7 +164,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
156164

157165
stdOut, stdErr, stdIOResult := feedback.OutputStreams()
158166
req := &rpc.UploadRequest{
159-
Instance: instance,
167+
Instance: inst,
160168
Fqbn: fqbn,
161169
SketchPath: path,
162170
Port: port,

0 commit comments

Comments
 (0)