@@ -35,14 +35,12 @@ import (
35
35
)
36
36
37
37
var (
38
- fqbn string
38
+ fqbn arguments. Fqbn
39
39
port arguments.Port
40
- verbose bool
41
- verify bool
42
40
interpreter string
43
41
importDir string
44
42
printInfo bool
45
- programmer string
43
+ programmer arguments. Programmer
46
44
tr = i18n .Tr
47
45
)
48
46
@@ -54,26 +52,20 @@ func NewCommand() *cobra.Command {
54
52
Long : tr ("Debug Arduino sketches. (this command opens an interactive gdb session)" ),
55
53
Example : " " + os .Args [0 ] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch" ,
56
54
Args : cobra .MaximumNArgs (1 ),
57
- Run : run ,
55
+ Run : runDebugCommand ,
58
56
}
59
57
60
- debugCommand .Flags ().StringVarP (& fqbn , "fqbn" , "b" , "" , tr ("Fully Qualified Board Name, e.g.: arduino:avr:uno" ))
61
- debugCommand .RegisterFlagCompletionFunc ("fqbn" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
62
- return arguments .GetInstalledBoards (), cobra .ShellCompDirectiveDefault
63
- })
58
+ fqbn .AddToCommand (debugCommand )
64
59
port .AddToCommand (debugCommand )
65
- debugCommand .Flags ().StringVarP (& programmer , "programmer" , "P" , "" , tr ("Programmer to use for debugging" ))
66
- debugCommand .RegisterFlagCompletionFunc ("programmer" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
67
- return arguments .GetInstalledProgrammers (), cobra .ShellCompDirectiveDefault
68
- })
60
+ programmer .AddToCommand (debugCommand )
69
61
debugCommand .Flags ().StringVar (& interpreter , "interpreter" , "console" , tr ("Debug interpreter e.g.: %s" , "console, mi, mi1, mi2, mi3" ))
70
62
debugCommand .Flags ().StringVarP (& importDir , "input-dir" , "" , "" , tr ("Directory containing binaries for debug." ))
71
63
debugCommand .Flags ().BoolVarP (& printInfo , "info" , "I" , false , tr ("Show metadata about the debug session instead of starting the debugger." ))
72
64
73
65
return debugCommand
74
66
}
75
67
76
- func run (command * cobra.Command , args []string ) {
68
+ func runDebugCommand (command * cobra.Command , args []string ) {
77
69
instance := instance .CreateAndInit ()
78
70
79
71
path := ""
@@ -87,12 +79,12 @@ func run(command *cobra.Command, args []string) {
87
79
88
80
debugConfigRequested := & dbg.DebugConfigRequest {
89
81
Instance : instance ,
90
- Fqbn : fqbn ,
82
+ Fqbn : fqbn . String () ,
91
83
SketchPath : sketchPath .String (),
92
84
Port : discoveryPort .ToRPC (),
93
85
Interpreter : interpreter ,
94
86
ImportDir : importDir ,
95
- Programmer : programmer ,
87
+ Programmer : programmer . String () ,
96
88
}
97
89
98
90
if printInfo {
0 commit comments