Skip to content

Commit 78e196f

Browse files
cmaglieper1234
andcommitted
Apply suggestions from code review
Co-authored-by: per1234 <[email protected]>
1 parent 50d17c4 commit 78e196f

File tree

5 files changed

+51
-40
lines changed

5 files changed

+51
-40
lines changed

Diff for: arduino/cores/fqbn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func ParseFQBN(fqbnIn string) (*FQBN, error) {
5151
for _, pair := range strings.Split(fqbnParts[3], ",") {
5252
parts := strings.SplitN(pair, "=", 2)
5353
if len(parts) != 2 {
54-
return nil, fmt.Errorf(tr("invalid config oprion: %s"), pair)
54+
return nil, fmt.Errorf(tr("invalid config option: %s"), pair)
5555
}
5656
k := strings.TrimSpace(parts[0])
5757
v := strings.TrimSpace(parts[1])

Diff for: cli/cli.go

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cli
1717

1818
import (
1919
"fmt"
20+
"io"
2021
"io/ioutil"
2122
"os"
2223
"strings"
@@ -142,6 +143,16 @@ func preRun(cmd *cobra.Command, args []string) {
142143
os.Exit(errorcodes.ErrBadArgument)
143144
}
144145

146+
// Push stdout through colorable
147+
r, w, err := os.Pipe()
148+
if err != nil {
149+
stdout := colorable.NewColorable(os.Stdout)
150+
os.Stdout = w
151+
go func() {
152+
io.Copy(stdout, r)
153+
}()
154+
}
155+
145156
//
146157
// Prepare logging
147158
//

Diff for: commands/core/uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func uninstallPlatformRelease(pm *packagemanager.PackageManager, platformRelease
8282
}
8383

8484
log.Info("Platform uninstalled")
85-
taskCB(&rpc.TaskProgress{Message: fmt.Sprintf(tr("Platofrm %s uninstalled"), platformRelease), Completed: true})
85+
taskCB(&rpc.TaskProgress{Message: fmt.Sprintf(tr("Platform %s uninstalled"), platformRelease), Completed: true})
8686
return nil
8787
}
8888

Diff for: commands/errors.go

+37-37
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (e *InvalidInstanceError) Error() string {
4343
return tr("Invalid instance")
4444
}
4545

46-
// ToRPCStatus convertes the error into a *status.Status
46+
// ToRPCStatus converts the error into a *status.Status
4747
func (e *InvalidInstanceError) ToRPCStatus() *status.Status {
4848
return status.New(codes.InvalidArgument, e.Error())
4949
}
@@ -57,7 +57,7 @@ func (e *InvalidFQBNError) Error() string {
5757
return composeErrorMsg(tr("Invalid FQBN"), e.Cause)
5858
}
5959

60-
// ToRPCStatus convertes the error into a *status.Status
60+
// ToRPCStatus converts the error into a *status.Status
6161
func (e *InvalidFQBNError) ToRPCStatus() *status.Status {
6262
return status.New(codes.InvalidArgument, e.Error())
6363
}
@@ -75,7 +75,7 @@ func (e *InvalidURLError) Error() string {
7575
return composeErrorMsg(tr("Invalid URL"), e.Cause)
7676
}
7777

78-
// ToRPCStatus convertes the error into a *status.Status
78+
// ToRPCStatus converts the error into a *status.Status
7979
func (e *InvalidURLError) ToRPCStatus() *status.Status {
8080
return status.New(codes.InvalidArgument, e.Error())
8181
}
@@ -93,7 +93,7 @@ func (e *InvalidLibraryError) Error() string {
9393
return composeErrorMsg(tr("Invalid library"), e.Cause)
9494
}
9595

96-
// ToRPCStatus convertes the error into a *status.Status
96+
// ToRPCStatus converts the error into a *status.Status
9797
func (e *InvalidLibraryError) ToRPCStatus() *status.Status {
9898
return status.New(codes.InvalidArgument, e.Error())
9999
}
@@ -111,7 +111,7 @@ func (e *InvalidVersionError) Error() string {
111111
return composeErrorMsg(tr("Invalid version"), e.Cause)
112112
}
113113

114-
// ToRPCStatus convertes the error into a *status.Status
114+
// ToRPCStatus converts the error into a *status.Status
115115
func (e *InvalidVersionError) ToRPCStatus() *status.Status {
116116
return status.New(codes.InvalidArgument, e.Error())
117117
}
@@ -127,7 +127,7 @@ func (e *MissingFQBNError) Error() string {
127127
return tr("Missing FQBN (Fully Qualified Board Name)")
128128
}
129129

130-
// ToRPCStatus convertes the error into a *status.Status
130+
// ToRPCStatus converts the error into a *status.Status
131131
func (e *MissingFQBNError) ToRPCStatus() *status.Status {
132132
return status.New(codes.InvalidArgument, e.Error())
133133
}
@@ -145,7 +145,7 @@ func (e *UnknownFQBNError) Unwrap() error {
145145
return e.Cause
146146
}
147147

148-
// ToRPCStatus convertes the error into a *status.Status
148+
// ToRPCStatus converts the error into a *status.Status
149149
func (e *UnknownFQBNError) ToRPCStatus() *status.Status {
150150
return status.New(codes.NotFound, e.Error())
151151
}
@@ -157,7 +157,7 @@ func (e *MissingPortProtocolError) Error() string {
157157
return tr("Missing port protocol")
158158
}
159159

160-
// ToRPCStatus convertes the error into a *status.Status
160+
// ToRPCStatus converts the error into a *status.Status
161161
func (e *MissingPortProtocolError) ToRPCStatus() *status.Status {
162162
return status.New(codes.InvalidArgument, e.Error())
163163
}
@@ -169,20 +169,20 @@ func (e *MissingProgrammerError) Error() string {
169169
return tr("Missing programmer")
170170
}
171171

172-
// ToRPCStatus convertes the error into a *status.Status
172+
// ToRPCStatus converts the error into a *status.Status
173173
func (e *MissingProgrammerError) ToRPCStatus() *status.Status {
174174
return status.New(codes.InvalidArgument, e.Error())
175175
}
176176

177-
// ProgreammerRequiredForUploadError is returned then the upload can be done only using a programmer
178-
type ProgreammerRequiredForUploadError struct{}
177+
// ProgrammerRequiredForUploadError is returned then the upload can be done only using a programmer
178+
type ProgrammerRequiredForUploadError struct{}
179179

180-
func (e *ProgreammerRequiredForUploadError) Error() string {
180+
func (e *ProgrammerRequiredForUploadError) Error() string {
181181
return tr("A programmer is required to upload")
182182
}
183183

184-
// ToRPCStatus convertes the error into a *status.Status
185-
func (e *ProgreammerRequiredForUploadError) ToRPCStatus() *status.Status {
184+
// ToRPCStatus converts the error into a *status.Status
185+
func (e *ProgrammerRequiredForUploadError) ToRPCStatus() *status.Status {
186186
st, _ := status.
187187
New(codes.InvalidArgument, e.Error()).
188188
WithDetails(&rpc.ProgrammerIsRequiredForUploadError{})
@@ -203,7 +203,7 @@ func (e *ProgrammerNotFoundError) Unwrap() error {
203203
return e.Cause
204204
}
205205

206-
// ToRPCStatus convertes the error into a *status.Status
206+
// ToRPCStatus converts the error into a *status.Status
207207
func (e *ProgrammerNotFoundError) ToRPCStatus() *status.Status {
208208
return status.New(codes.NotFound, e.Error())
209209
}
@@ -218,7 +218,7 @@ func (e *InvalidPlatformPropertyError) Error() string {
218218
return tr("Invalid '%[1]s' property: %[2]s", e.Property, e.Value)
219219
}
220220

221-
// ToRPCStatus convertes the error into a *status.Status
221+
// ToRPCStatus converts the error into a *status.Status
222222
func (e *InvalidPlatformPropertyError) ToRPCStatus() *status.Status {
223223
return status.New(codes.FailedPrecondition, e.Error())
224224
}
@@ -232,7 +232,7 @@ func (e *MissingPlatformPropertyError) Error() string {
232232
return tr("Property '%s' is undefined", e.Property)
233233
}
234234

235-
// ToRPCStatus convertes the error into a *status.Status
235+
// ToRPCStatus converts the error into a *status.Status
236236
func (e *MissingPlatformPropertyError) ToRPCStatus() *status.Status {
237237
return status.New(codes.FailedPrecondition, e.Error())
238238
}
@@ -247,7 +247,7 @@ func (e *PlatformNotFound) Error() string {
247247
return composeErrorMsg(tr("Platform '%s' not found", e.Platform), e.Cause)
248248
}
249249

250-
// ToRPCStatus convertes the error into a *status.Status
250+
// ToRPCStatus converts the error into a *status.Status
251251
func (e *PlatformNotFound) ToRPCStatus() *status.Status {
252252
return status.New(codes.FailedPrecondition, e.Error())
253253
}
@@ -266,7 +266,7 @@ func (e *LibraryNotFound) Error() string {
266266
return composeErrorMsg(tr("Library '%s' not found", e.Library), e.Cause)
267267
}
268268

269-
// ToRPCStatus convertes the error into a *status.Status
269+
// ToRPCStatus converts the error into a *status.Status
270270
func (e *LibraryNotFound) ToRPCStatus() *status.Status {
271271
return status.New(codes.FailedPrecondition, e.Error())
272272
}
@@ -285,7 +285,7 @@ func (e *LibraryDependenciesResolutionFailedError) Error() string {
285285
return composeErrorMsg(tr("No valid dependencies solution found"), e.Cause)
286286
}
287287

288-
// ToRPCStatus convertes the error into a *status.Status
288+
// ToRPCStatus converts the error into a *status.Status
289289
func (e *LibraryDependenciesResolutionFailedError) ToRPCStatus() *status.Status {
290290
return status.New(codes.FailedPrecondition, e.Error())
291291
}
@@ -303,7 +303,7 @@ func (e *PlatformAlreadyAtTheLatestVersionError) Error() string {
303303
return tr("Platform '%s' is already at the latest version", e.Platform)
304304
}
305305

306-
// ToRPCStatus convertes the error into a *status.Status
306+
// ToRPCStatus converts the error into a *status.Status
307307
func (e *PlatformAlreadyAtTheLatestVersionError) ToRPCStatus() *status.Status {
308308
st, _ := status.
309309
New(codes.AlreadyExists, e.Error()).
@@ -318,7 +318,7 @@ func (e *MissingSketchPathError) Error() string {
318318
return tr("Missing sketch path")
319319
}
320320

321-
// ToRPCStatus convertes the error into a *status.Status
321+
// ToRPCStatus converts the error into a *status.Status
322322
func (e *MissingSketchPathError) ToRPCStatus() *status.Status {
323323
return status.New(codes.InvalidArgument, e.Error())
324324
}
@@ -336,7 +336,7 @@ func (e *CantOpenSketchError) Unwrap() error {
336336
return e.Cause
337337
}
338338

339-
// ToRPCStatus convertes the error into a *status.Status
339+
// ToRPCStatus converts the error into a *status.Status
340340
func (e *CantOpenSketchError) ToRPCStatus() *status.Status {
341341
return status.New(codes.NotFound, e.Error())
342342
}
@@ -355,7 +355,7 @@ func (e *FailedInstallError) Unwrap() error {
355355
return e.Cause
356356
}
357357

358-
// ToRPCStatus convertes the error into a *status.Status
358+
// ToRPCStatus converts the error into a *status.Status
359359
func (e *FailedInstallError) ToRPCStatus() *status.Status {
360360
return status.New(codes.Internal, e.Error())
361361
}
@@ -373,7 +373,7 @@ func (e *FailedLibraryInstallError) Unwrap() error {
373373
return e.Cause
374374
}
375375

376-
// ToRPCStatus convertes the error into a *status.Status
376+
// ToRPCStatus converts the error into a *status.Status
377377
func (e *FailedLibraryInstallError) ToRPCStatus() *status.Status {
378378
return status.New(codes.Internal, e.Error())
379379
}
@@ -392,7 +392,7 @@ func (e *FailedUninstallError) Unwrap() error {
392392
return e.Cause
393393
}
394394

395-
// ToRPCStatus convertes the error into a *status.Status
395+
// ToRPCStatus converts the error into a *status.Status
396396
func (e *FailedUninstallError) ToRPCStatus() *status.Status {
397397
return status.New(codes.Internal, e.Error())
398398
}
@@ -411,7 +411,7 @@ func (e *FailedDownloadError) Unwrap() error {
411411
return e.Cause
412412
}
413413

414-
// ToRPCStatus convertes the error into a *status.Status
414+
// ToRPCStatus converts the error into a *status.Status
415415
func (e *FailedDownloadError) ToRPCStatus() *status.Status {
416416
return status.New(codes.Internal, e.Error())
417417
}
@@ -430,7 +430,7 @@ func (e *FailedUploadError) Unwrap() error {
430430
return e.Cause
431431
}
432432

433-
// ToRPCStatus convertes the error into a *status.Status
433+
// ToRPCStatus converts the error into a *status.Status
434434
func (e *FailedUploadError) ToRPCStatus() *status.Status {
435435
return status.New(codes.Internal, e.Error())
436436
}
@@ -449,7 +449,7 @@ func (e *FailedDebugError) Unwrap() error {
449449
return e.Cause
450450
}
451451

452-
// ToRPCStatus convertes the error into a *status.Status
452+
// ToRPCStatus converts the error into a *status.Status
453453
func (e *FailedDebugError) ToRPCStatus() *status.Status {
454454
return status.New(codes.Internal, e.Error())
455455
}
@@ -468,7 +468,7 @@ func (e *CompileFailedError) Unwrap() error {
468468
return e.Cause
469469
}
470470

471-
// ToRPCStatus convertes the error into a *status.Status
471+
// ToRPCStatus converts the error into a *status.Status
472472
func (e *CompileFailedError) ToRPCStatus() *status.Status {
473473
return status.New(codes.Internal, e.Error())
474474
}
@@ -487,7 +487,7 @@ func (e *InvalidArgumentError) Unwrap() error {
487487
return e.Cause
488488
}
489489

490-
// ToRPCStatus convertes the error into a *status.Status
490+
// ToRPCStatus converts the error into a *status.Status
491491
func (e *InvalidArgumentError) ToRPCStatus() *status.Status {
492492
return status.New(codes.InvalidArgument, e.Error())
493493
}
@@ -506,7 +506,7 @@ func (e *NotFoundError) Unwrap() error {
506506
return e.Cause
507507
}
508508

509-
// ToRPCStatus convertes the error into a *status.Status
509+
// ToRPCStatus converts the error into a *status.Status
510510
func (e *NotFoundError) ToRPCStatus() *status.Status {
511511
return status.New(codes.NotFound, e.Error())
512512
}
@@ -525,7 +525,7 @@ func (e *PermissionDeniedError) Unwrap() error {
525525
return e.Cause
526526
}
527527

528-
// ToRPCStatus convertes the error into a *status.Status
528+
// ToRPCStatus converts the error into a *status.Status
529529
func (e *PermissionDeniedError) ToRPCStatus() *status.Status {
530530
return status.New(codes.PermissionDenied, e.Error())
531531
}
@@ -544,7 +544,7 @@ func (e *UnavailableError) Unwrap() error {
544544
return e.Cause
545545
}
546546

547-
// ToRPCStatus convertes the error into a *status.Status
547+
// ToRPCStatus converts the error into a *status.Status
548548
func (e *UnavailableError) ToRPCStatus() *status.Status {
549549
return status.New(codes.Unavailable, e.Error())
550550
}
@@ -562,7 +562,7 @@ func (e *TempDirCreationFailedError) Unwrap() error {
562562
return e.Cause
563563
}
564564

565-
// ToRPCStatus convertes the error into a *status.Status
565+
// ToRPCStatus converts the error into a *status.Status
566566
func (e *TempDirCreationFailedError) ToRPCStatus() *status.Status {
567567
return status.New(codes.Unavailable, e.Error())
568568
}
@@ -580,7 +580,7 @@ func (e *TempFileCreationFailedError) Unwrap() error {
580580
return e.Cause
581581
}
582582

583-
// ToRPCStatus convertes the error into a *status.Status
583+
// ToRPCStatus converts the error into a *status.Status
584584
func (e *TempFileCreationFailedError) ToRPCStatus() *status.Status {
585585
return status.New(codes.Unavailable, e.Error())
586586
}
@@ -599,7 +599,7 @@ func (e *SignatureVerificationFailedError) Unwrap() error {
599599
return e.Cause
600600
}
601601

602-
// ToRPCStatus convertes the error into a *status.Status
602+
// ToRPCStatus converts the error into a *status.Status
603603
func (e *SignatureVerificationFailedError) ToRPCStatus() *status.Status {
604604
return status.New(codes.Unavailable, e.Error())
605605
}

Diff for: commands/upload/upload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func runProgramAction(pm *packagemanager.PackageManager,
304304
}
305305

306306
if !uploadProperties.ContainsKey("upload.protocol") && programmer == nil {
307-
return &commands.ProgreammerRequiredForUploadError{}
307+
return &commands.ProgrammerRequiredForUploadError{}
308308
}
309309

310310
// Set properties for verbose upload

0 commit comments

Comments
 (0)