@@ -90,13 +90,6 @@ func runMonitorCmd(
90
90
quiet = true
91
91
}
92
92
93
- var (
94
- inst * rpc.Instance
95
- profile * rpc.SketchProfile
96
- fqbn string
97
- defaultPort , defaultProtocol string
98
- )
99
-
100
93
// Flags takes maximum precedence over sketch.yaml
101
94
// If {--port --fqbn --profile} are set we ignore the profile.
102
95
// If both {--port --profile} are set we read the fqbn in the following order: profile -> default_fqbn -> discovery
@@ -111,9 +104,9 @@ func runMonitorCmd(
111
104
)
112
105
}
113
106
sketch := resp .GetSketch ()
114
- if sketch != nil {
115
- defaultPort , defaultProtocol = sketch . GetDefaultPort (), sketch . GetDefaultProtocol ()
116
- }
107
+
108
+ var inst * rpc. Instance
109
+ var profile * rpc. SketchProfile
117
110
if fqbnArg .String () == "" {
118
111
if profileArg .Get () == "" {
119
112
inst , profile = instance .CreateAndInitWithProfile (ctx , srv , sketch .GetDefaultProfile ().GetName (), sketchPath )
@@ -130,6 +123,7 @@ func runMonitorCmd(
130
123
// 2. from profile
131
124
// 3. from default_fqbn specified in the sketch.yaml
132
125
// 4. try to detect from the port
126
+ var fqbn string
133
127
switch {
134
128
case fqbnArg .String () != "" :
135
129
fqbn = fqbnArg .String ()
@@ -141,6 +135,10 @@ func runMonitorCmd(
141
135
fqbn , _ , _ = portArgs .DetectFQBN (ctx , inst , srv )
142
136
}
143
137
138
+ var defaultPort , defaultProtocol string
139
+ if sketch != nil {
140
+ defaultPort , defaultProtocol = sketch .GetDefaultPort (), sketch .GetDefaultProtocol ()
141
+ }
144
142
portAddress , portProtocol , err := portArgs .GetPortAddressAndProtocol (ctx , inst , srv , defaultPort , defaultProtocol )
145
143
if err != nil {
146
144
feedback .FatalError (err , feedback .ErrGeneric )
0 commit comments