Skip to content

Commit 53b6c88

Browse files
committed
Allow port/protocol in profiles
1 parent 373aa18 commit 53b6c88

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

internal/cli/arguments/fqbn.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (f *Fqbn) Set(fqbn string) {
7171
// - the port is not found, in this case nil is returned
7272
// - the FQBN autodetection fail, in this case the function prints an error and
7373
// terminates the execution
74-
func CalculateFQBNAndPort(ctx context.Context, portArgs *Port, fqbnArg *Fqbn, instance *rpc.Instance, srv rpc.ArduinoCoreServiceServer, defaultFQBN, defaultAddress, defaultProtocol string) (string, *rpc.Port) {
74+
func CalculateFQBNAndPort(ctx context.Context, portArgs *Port, fqbnArg *Fqbn, instance *rpc.Instance, srv rpc.ArduinoCoreServiceServer, defaultFQBN, defaultAddress, defaultProtocol string, profile *rpc.SketchProfile) (string, *rpc.Port) {
7575
fqbn := fqbnArg.String()
7676
if fqbn == "" {
7777
fqbn = defaultFQBN
@@ -87,6 +87,12 @@ func CalculateFQBNAndPort(ctx context.Context, portArgs *Port, fqbnArg *Fqbn, in
8787
return fqbn, port
8888
}
8989

90+
if profile.GetPort() != "" {
91+
defaultAddress = profile.GetPort()
92+
}
93+
if profile.GetProtocol() != "" {
94+
defaultProtocol = profile.GetProtocol()
95+
}
9096
port, err := portArgs.GetPort(ctx, instance, srv, defaultAddress, defaultProtocol)
9197
if err != nil {
9298
feedback.Fatal(i18n.Tr("Error getting port metadata: %v", err), feedback.ErrGeneric)

internal/cli/compile/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func runCompileCommand(cmd *cobra.Command, args []string, srv rpc.ArduinoCoreSer
180180
fqbnArg.Set(profile.GetFqbn())
181181
}
182182

183-
fqbn, port := arguments.CalculateFQBNAndPort(ctx, &portArgs, &fqbnArg, inst, srv, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol())
183+
fqbn, port := arguments.CalculateFQBNAndPort(ctx, &portArgs, &fqbnArg, inst, srv, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol(), profile)
184184

185185
if keysKeychain != "" || signKey != "" || encryptKey != "" {
186186
arguments.CheckFlagsMandatory(cmd, "keys-keychain", "sign-key", "encrypt-key")

internal/cli/debug/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func runDebugCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args
108108
fqbnArg.Set(profile.GetFqbn())
109109
}
110110

111-
fqbn, port := arguments.CalculateFQBNAndPort(ctx, portArgs, fqbnArg, inst, srv, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol())
111+
fqbn, port := arguments.CalculateFQBNAndPort(ctx, portArgs, fqbnArg, inst, srv, sk.GetDefaultFqbn(), sk.GetDefaultPort(), sk.GetDefaultProtocol(), profile)
112112

113113
prog := profile.GetProgrammer()
114114
if prog == "" || programmer.GetProgrammer() != "" {

internal/cli/upload/upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func runUploadCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, arg
117117
defaultFQBN := sketch.GetDefaultFqbn()
118118
defaultAddress := sketch.GetDefaultPort()
119119
defaultProtocol := sketch.GetDefaultProtocol()
120-
fqbn, port := arguments.CalculateFQBNAndPort(ctx, &portArgs, &fqbnArg, inst, srv, defaultFQBN, defaultAddress, defaultProtocol)
120+
fqbn, port := arguments.CalculateFQBNAndPort(ctx, &portArgs, &fqbnArg, inst, srv, defaultFQBN, defaultAddress, defaultProtocol, profile)
121121

122122
userFieldRes, err := srv.SupportedUserFields(ctx, &rpc.SupportedUserFieldsRequest{
123123
Instance: inst,

0 commit comments

Comments
 (0)