@@ -43,6 +43,7 @@ func NewCommand() *cobra.Command {
43
43
var (
44
44
fqbnArg arguments.Fqbn
45
45
portArgs arguments.Port
46
+ profileArg arguments.Profile
46
47
interpreter string
47
48
importDir string
48
49
printInfo bool
@@ -56,14 +57,15 @@ func NewCommand() *cobra.Command {
56
57
Example : " " + os .Args [0 ] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch" ,
57
58
Args : cobra .MaximumNArgs (1 ),
58
59
Run : func (cmd * cobra.Command , args []string ) {
59
- runDebugCommand (args , & portArgs , & fqbnArg , interpreter , importDir , & programmer , printInfo )
60
+ runDebugCommand (args , & portArgs , & fqbnArg , interpreter , importDir , & programmer , printInfo , & profileArg )
60
61
},
61
62
}
62
63
63
64
debugCommand .AddCommand (newDebugCheckCommand ())
64
65
fqbnArg .AddToCommand (debugCommand )
65
66
portArgs .AddToCommand (debugCommand )
66
67
programmer .AddToCommand (debugCommand )
68
+ profileArg .AddToCommand (debugCommand )
67
69
debugCommand .Flags ().StringVar (& interpreter , "interpreter" , "console" , tr ("Debug interpreter e.g.: %s" , "console, mi, mi1, mi2, mi3" ))
68
70
debugCommand .Flags ().StringVarP (& importDir , "input-dir" , "" , "" , tr ("Directory containing binaries for debug." ))
69
71
debugCommand .Flags ().BoolVarP (& printInfo , "info" , "I" , false , tr ("Show metadata about the debug session instead of starting the debugger." ))
@@ -72,8 +74,7 @@ func NewCommand() *cobra.Command {
72
74
}
73
75
74
76
func runDebugCommand (args []string , portArgs * arguments.Port , fqbnArg * arguments.Fqbn ,
75
- interpreter string , importDir string , programmer * arguments.Programmer , printInfo bool ) {
76
- instance := instance .CreateAndInit ()
77
+ interpreter string , importDir string , programmer * arguments.Programmer , printInfo bool , profileArg * arguments.Profile ) {
77
78
logrus .Info ("Executing `arduino-cli debug`" )
78
79
79
80
path := ""
@@ -88,15 +89,34 @@ func runDebugCommand(args []string, portArgs *arguments.Port, fqbnArg *arguments
88
89
}
89
90
feedback .WarnAboutDeprecatedFiles (sk )
90
91
91
- fqbn , port := arguments .CalculateFQBNAndPort (portArgs , fqbnArg , instance , sk .GetDefaultFqbn (), sk .GetDefaultPort (), sk .GetDefaultProtocol ())
92
+ var inst * rpc.Instance
93
+ var profile * rpc.Profile
94
+
95
+ if profileArg .Get () == "" {
96
+ inst , profile = instance .CreateAndInitWithProfile (sk .GetDefaultProfile ().GetName (), sketchPath )
97
+ } else {
98
+ inst , profile = instance .CreateAndInitWithProfile (profileArg .Get (), sketchPath )
99
+ }
100
+
101
+ if fqbnArg .String () == "" {
102
+ fqbnArg .Set (profile .GetFqbn ())
103
+ }
104
+
105
+ fqbn , port := arguments .CalculateFQBNAndPort (portArgs , fqbnArg , inst , sk .GetDefaultFqbn (), sk .GetDefaultPort (), sk .GetDefaultProtocol ())
106
+
107
+ prog := profile .GetProgrammer ()
108
+ if prog == "" || programmer .GetProgrammer () != "" {
109
+ prog = programmer .String (inst , fqbn )
110
+ }
111
+
92
112
debugConfigRequested := & rpc.GetDebugConfigRequest {
93
- Instance : instance ,
113
+ Instance : inst ,
94
114
Fqbn : fqbn ,
95
115
SketchPath : sketchPath .String (),
96
116
Port : port ,
97
117
Interpreter : interpreter ,
98
118
ImportDir : importDir ,
99
- Programmer : programmer . String ( instance , fqbn ) ,
119
+ Programmer : prog ,
100
120
}
101
121
102
122
if printInfo {
0 commit comments