@@ -37,17 +37,18 @@ import (
37
37
"github.com/spf13/cobra"
38
38
)
39
39
40
- var tr = i18n .Tr
41
-
42
- var portArgs arguments.Port
43
- var describe bool
44
- var configs []string
45
- var quiet bool
46
- var fqbn string
40
+ var (
41
+ portArgs arguments.Port
42
+ describe bool
43
+ configs []string
44
+ quiet bool
45
+ fqbn arguments.Fqbn
46
+ tr = i18n .Tr
47
+ )
47
48
48
49
// NewCommand created a new `monitor` command
49
50
func NewCommand () * cobra.Command {
50
- cmd := & cobra.Command {
51
+ monitorCommand := & cobra.Command {
51
52
Use : "monitor" ,
52
53
Short : tr ("Open a communication port with a board." ),
53
54
Long : tr ("Open a communication port with a board." ),
@@ -56,16 +57,13 @@ func NewCommand() *cobra.Command {
56
57
" " + os .Args [0 ] + " monitor -p /dev/ttyACM0 --describe" ,
57
58
Run : runMonitorCmd ,
58
59
}
59
- portArgs .AddToCommand (cmd )
60
- cmd .Flags ().BoolVar (& describe , "describe" , false , tr ("Show all the settings of the communication port." ))
61
- cmd .Flags ().StringSliceVarP (& configs , "config" , "c" , []string {}, tr ("Configuration of the port." ))
62
- cmd .Flags ().BoolVarP (& quiet , "quiet" , "q" , false , tr ("Run in silent mode, show only monitor input and output." ))
63
- cmd .Flags ().StringVarP (& fqbn , "fqbn" , "b" , "" , tr ("Fully Qualified Board Name, e.g.: arduino:avr:uno" ))
64
- cmd .RegisterFlagCompletionFunc ("fqbn" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
65
- return arguments .GetInstalledBoards (), cobra .ShellCompDirectiveDefault
66
- })
67
- cmd .MarkFlagRequired ("port" )
68
- return cmd
60
+ portArgs .AddToCommand (monitorCommand )
61
+ monitorCommand .Flags ().BoolVar (& describe , "describe" , false , tr ("Show all the settings of the communication port." ))
62
+ monitorCommand .Flags ().StringSliceVarP (& configs , "config" , "c" , []string {}, tr ("Configuration of the port." ))
63
+ monitorCommand .Flags ().BoolVarP (& quiet , "quiet" , "q" , false , tr ("Run in silent mode, show only monitor input and output." ))
64
+ fqbn .AddToCommand (monitorCommand )
65
+ monitorCommand .MarkFlagRequired ("port" )
66
+ return monitorCommand
69
67
}
70
68
71
69
func runMonitorCmd (cmd * cobra.Command , args []string ) {
@@ -84,7 +82,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
84
82
enumerateResp , err := monitor .EnumerateMonitorPortSettings (context .Background (), & rpc.EnumerateMonitorPortSettingsRequest {
85
83
Instance : instance ,
86
84
PortProtocol : portProtocol ,
87
- Fqbn : fqbn ,
85
+ Fqbn : fqbn . String () ,
88
86
})
89
87
if err != nil {
90
88
feedback .Error (tr ("Error getting port settings details: %s" , err ))
@@ -148,7 +146,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
148
146
portProxy , _ , err := monitor .Monitor (context .Background (), & rpc.MonitorRequest {
149
147
Instance : instance ,
150
148
Port : & rpc.Port {Address : portAddress , Protocol : portProtocol },
151
- Fqbn : fqbn ,
149
+ Fqbn : fqbn . String () ,
152
150
PortConfiguration : configuration ,
153
151
})
154
152
if err != nil {
0 commit comments