Skip to content

Commit b3b36c6

Browse files
Add support for default profile to compile command
1 parent 29234b7 commit b3b36c6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,25 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
159159
}
160160

161161
sketchPath := arguments.InitSketchPath(path)
162-
inst, profile := instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath)
163-
if fqbnArg.String() == "" {
164-
fqbnArg.Set(profile.GetFqbn())
165-
}
166162

167163
sk, err := sketch.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()})
168164
if err != nil {
169165
feedback.FatalError(err, feedback.ErrGeneric)
170166
}
167+
168+
var inst *rpc.Instance
169+
var profile *rpc.Profile
170+
171+
if profileArg.Get() == "" {
172+
inst, profile = instance.CreateAndInitWithProfile(sk.GetDefaultProfile().GetName(), sketchPath)
173+
} else {
174+
inst, profile = instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath)
175+
}
176+
177+
if fqbnArg.String() == "" {
178+
fqbnArg.Set(profile.GetFqbn())
179+
}
180+
171181
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, inst, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol())
172182

173183
if keysKeychain != "" || signKey != "" || encryptKey != "" {

0 commit comments

Comments
 (0)